Track Google Analytics and then redirect ..?

I have a WordPress plugin in which I am going to run advertising campaigns, and I would like to send users directly to the plugin directory page , but I need to register traffic so that it displays in my Google Analytics.

I am trying to create a small β€œaverage person” script I can use for this, but I am struggling to find a working solution out of all the potential that I find.

I am using the new Google Analytics tracking code:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-2xxxx3-1', 'angelleye.com');
  ga('send', 'pageview');

</script>

From what I read, I need to add javascript redirects to it, but the delay is 1 or 2 seconds, so that Google Analytics has time to track before the redirect occurs. I'm not good enough with javascript to do this, I think.

Any information would be greatly appreciated. Thank!

+4
source share
2 answers

Just create a custom page on your website with the Google Analytics + Redirect Code. You can use JavaScript redirect code, for example:

<script type="text/javascript">
    setTimeout(function()
        {
        alert("Hello")
        //location.href="http://wordpress.org/plugins/paypal-for-woocommerce/"
    },3000);
</script>

Just comment on the alert and uncomment the redirect ...

0
source

, Google , WP. , , , , . 3 :

  • "Link Click Listener", " ".
  • LinkOut ( Google Analytics) UGA ( Google Analytics) :

{{event}} = gtm.linkClick

{{element url}} wordpress.org/plugins/yourpluginnamehere

  • UGA,

!

0

Source: https://habr.com/ru/post/1533308/


All Articles