3

The new Universal Analytics re-introduces synchronous event tracking: https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#sync.

The documentation however is incomplete, it says:

"This calling syntax will not work when loading the analytics.js library using the default snippet. The default snippet is designed to work with the asynchronous calling syntax."

So now I've only got a default (asynchronous) snippet:

<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-XXXXX-YY', 'mydomain.com');
 ga('send', 'pageview');
</script>

I can't find any mention of the correct snippet for synchronous calls. Anyone?

asked Aug 9, 2013 at 11:59

1 Answer 1

6

Use this one:

<script src="//www.google-analytics.com/analytics.js"></script>
 <script> 
 var tracker = ga.create('UA-12345678-1', 'auto');
 tracker.send('pageview');
 </script>

Tested.

answered Jan 9, 2014 at 9:11
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.