Google Analytics - Upgrade to Async Code

We have an older site that still uses the ancient Google Analytics tracking code (pre asynchronous); we would like to update it to the current asynchronous gaq code.

If someone made the same switch, a couple of questions ...

1) As soon as we make the switch, will the user's cookies be transferred from the old code? Or will Analytics now โ€œforgetโ€ visitors who have already visited our site and consider everyone who receives an updated asynchronous snippet of new visitor code?

2) The site is quite complex; weโ€™ll probably have to โ€œhuntโ€ for all sections of the site that have the old tracking code. While we are doing this code cleanup, will the old "gat" code and the new "gaq" code be compatible? This means that they will correctly count page views, will not lose referrer information and only count one visit, even if the user clicks on both pages that contain the old code and those that contain the new code during their visit?

Thanks! And just for reference, here is 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> 
+2
source share
1 answer

If your implementation is as simple as tracking page views, or otherwise, if you are not using legacy GA methods to perform custom tracking of user actions or browser functions, or something else, then your answers:

  • GA will remember visitors.
    The rationale for this is simple: the code you use on the page is not the one that GA uses to track people. The .js file they call in document.write(); parts of the script used to track people and set cookies and everything else.
    They updated this file dozens of times, without noticing, due to the way they separated their logic (in this file) from the tracking interface used (which remained the same all the time).

  • There will be no problem with the presence of some pages in the old code (again, if you do not perform any advanced tracking from page to page, based on very new or very old functions that are more advanced than tracking user variables, tracking purchases and tracking views pages).
    One of the conditions here is that you DO NOT LEAVE THEM ONE PAGE .
    This will lead to both shelling and the collection of the same data, and you will basically double your performance.

+3
source

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


All Articles