dubesor
dubesor

Reputation: 337

Google Analytics - Upgrading to Async Code

We have an older site which still uses the ancient "gat" Analytics tracking code (pre asynchronous); we would like to upgrade it to the current "gaq" asynchronous code.

If anyone has done the same switch, a couple questions ...

1) Once we make the switch, will the user cookies carry over from the old code? Or will Analytics now "forget" visitors that have already visited our site and consider everyone that gets the updated asynchronous code snippet a brand new visitor?

2) The site is pretty complex; we'll probably have to "hunt" for all the sections of the site that have the old tracking code on them. While we do this code cleanup, will the old "gat" code and the new "gaq" code be compatible? Meaning they'll both count pageviews properly, will not lose referrer info, and count just one visit even if the user hits both pages containing the old code and those containing the new code during their visit?

Thanks! And just for reference, here's our current (old) code:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-#######-#");
pageTracker._trackPageview();
} catch(err) {}</script>

Upvotes: 2

Views: 914

Answers (1)

LetterEh
LetterEh

Reputation: 26696

If your implementation is as simple as tracking the pageviews -- or another way, if you aren't heavily using deprecated GA methods, to do custom-tracking of user-actions, or browser-features or whatever else, then here are your answers:

  1. GA will remember the visitors.
    The reasoning behind this is simple: the code you have on the page isn't what GA uses to track people -- the .js file that they call in the document.write(); portion of the script is what they use to track people and set cookies and all of the rest.
    They have updated that file dozens of times, without you noticing, because of how they've separated their logic (in that file), from the tracking-interface that you use (which has stayed the same all that time).

  2. There won't be any problems with having some pages on the old code (again, as long as you aren't doing any advanced tracking from page to page, based on very-new or very-old features that are more advanced than tracking custom variables, tracking purchases and tracking pageviews).
    The one stipulation here is that you DO NOT LEAVE THEM BOTH ON THE SAME PAGE.
    That would result in both firing, and both collecting the same data, and you'd basically be doubling your metrics.

Upvotes: 3

Related Questions