Skip to main content
Solved

Custom metric installation on Wordpress

  • May 9, 2024
  • 1 reply
  • 23 views

Forum|alt.badge.img+4

Hi all,

I want to create a flow for someone who reaches a URL on my website, I have added this custom code on the page of that URL via Google Tag Manager (GTM), it is not working and unable to see the metric on Klaviyo, any suggestions.

<script type="text/javascript"> 
//Script to initialize Klaviyo object on page load
!function(){if(!window.klaviyo){window._klOnsite=window._klOnsite||[];try{window.klaviyo=new Proxy({},{get:function(n,i){return"push"===i?function(){var n;(n=window._klOnsite).push.apply(n,arguments)}:function(){for(var n=arguments.length,o=new Array(n),w=0;w<n;w++)o[w]=arguments[w];var t="function"==typeof o[o.length-1]?o.pop():void 0,e=new Promise((function(n){window._klOnsite.push([i].concat(o,[function(i){t&&t(i),n(i)}]))}));return e}}})}catch(n){window.klaviyo=window.klaviyo||[],window.klaviyo.push=function(){var n;(n=window._klOnsite).push.apply(n,arguments)}}}}(); </script>
<script type="text/javascript"> 
//Script to track viewed page
klaviyo.track("Viewed Page", {           
      url: window.location.href   
}); 
</script>
 

Best answer by Brian Turcotte

Hi @USMarketer!

May I ask how you’re testing this? 

 

- Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • May 14, 2024

Hi @USMarketer!

May I ask how you’re testing this? 

 

- Brian