Unstoppable Domains

Which Google Analytics code to use

Spaceship Spaceship
Watch
Impact
5,565
I found the following two code snippets from Google's site. Can someone explain their difference and when to use them. (In my Google Analytics account, only the second method is mentioned.)


Method 1:
Source: Adding the tracking code (traditional) - Analytics Help

<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-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script>

Method 2:
Source: Set up the tracking code (asynchronous) - Analytics Help



<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
0
•••
Thanks todosa. I read the explanation but still couldn't understand very well.

I guess my question is: when is the traditional method preferred to the asynchronous method? When would you use the former?
 
0
•••
The answer to your question is that traditional method is made for quick and easy counting.

Asynchronous is for detailed and andvansed counting.

Оf course - this is my opinion
 
0
•••
OK, so if I use the traditional method, I'll get less information in GA reports. Thanks
 
0
•••
You'll get let, but you will just get the info that is more likely to be useful to you anyway. No need to get overwhelmed with too much info.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back