Quantcast
Channel: Savio.no - Blog
Viewing all articles
Browse latest Browse all 31

Javascript Redirect & Google Analytics Cross Domain Tracking

$
0
0

Recently I had to write a Javascript redirect function that supports Google Analytics cross domain tracking. You find this function below.

The function below has a 5 second delay before it redirects. Change values in red according to your needs.

Remove formatting from Code

  1. <script type="text/javascript">
  2. _gaq.push(function() {
  3. var myRedirectURL = 'http://www.domain2.com/';
  4. var pageTracker = _gat._getTrackerByName();
  5. myRedirect = pageTracker._getLinkerUrl(myRedirectURL);
  6. setTimeout("document.location.replace(\myRedirect\);", 5000);
  7. });
  8. </script>

Also remember that you should normally add a regular link on that redirect page for those who have javascript turned off.

If you think the piece of code could be improved, feel fra to comment (I'm not a programmer). Happy Google Analytics cross domain tracking using Javascript redirect.


Viewing all articles
Browse latest Browse all 31

Trending Articles