Hi all,

we are having problems tracking flowplayer video events with google analytics. We achieved it applying a timeout to the js code, but we are unnable without it.

According to this page, we need to put this code:

<script type="text/javascript">
var _tracker = _gat._getTracker("[YOUR TRACKING CODE]");
</script>

Directly after the <script src="http://www.google-analytics.com/ga.js"></script> call.

So, we added var _tracker = _gat._getTracker("[YOUR TRACKING CODE]");, in our analytics conf page, on the after snippet. But firebugging it, the problem with that setup is that without the timeout, the object is undefined, so no event is tracked.

At least it works, but seems a little dirty for me... any idea? Thanks in advance, Simon.

Comments

hass’s picture

Status: Active » Fixed

You need to upgrade to async code version.

SimonVlc’s picture

That's the 6.3.3 hass?

Thx!

hass’s picture

3.x is async

SimonVlc’s picture

I´ve updated to 6.3.3, but I´m still unable to load correctly the object. This is the error on firebug:

_gat is not defined

Any help will be appreciated!

hass’s picture

Your code is not async. It need to be upgraded.

SimonVlc’s picture

Hi hass,

I´ve installed 6.3.3, run update.php, and everything seems updated (non updates pending).

This is the analytics code that appears on my page (without the flowplayer js added):

<!--//--><![CDATA[//><!--
var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-XXXXX-XX"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = "/sites/default/files/googleanalytics/ga.js?z";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();
//--><!]]>
</script> 

So, please hass, what are you telling when talk about 'it need to be upgraded'? Thanks in advance!

hass’s picture

<script type="text/javascript">
var _tracker = _gat._getTracker("[YOUR TRACKING CODE]");
</script>

This is *synchronous* code and needs to be upgraded to async and above is invalid with async GA versions. This is why nothing gets logged.

SimonVlc’s picture

Thanks for your help hass, you were rigth ;).

For reference, this is the async version of the code:

_gaq.push(['_tracker._setAccount', 'UA-xxxxx-xx']);

hass’s picture

Aside you schould be able to push an event without creating a new tracker, but you may track it in different accounts and therefore it may be required.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.