0
votes

I'm running google analytics in the head of the page. For performance I'm loading other code like facebook or jQuery Business Logic async deferred at the end of the body.

Is google universal analytics tracking correctly if ga('set', 'contentGroup1', 'Cat1') or ga('set', 'dimension1', 'customdimension1'); are fired anythere in the body and not before ga('send','pageview')?

Schematic Example:

<html>
    <head>
        ...
        ga('send','pageview')
        ...
    </head>
    <body>
        ga('set', 'contentGroup1', 'Cat1')
    </body>
</html>
1

1 Answers

1
votes

The documentation says about set:

The values that are set will persist with all the subsequent send calls for the lifetime of the tracker object.

So it does not work for previous calls to send pageview (which makes sense - per documentation send "sends a tracking beacon to Google’s collection servers" and later method calls cannot modify what already has been sent). While the analytics code is executed asynchronously (which is probably why you are asking) the tracking calls are still executed in the sequence in which they were set.