On the one site I am working, the main part of the tracking code is at the bottom of the page (I do not like the appointment , But that's where it is). The code is main:
var _gaq = _gaq || []; _gaq.push (['_ setAccount', 'UA-XXXXXXXX-X']); _gaq.push (['_ trackPageview']); (Function () {var ga = document.createElement ('script'); ga.type = 'text / javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol? 'Http: //ssl': 'http: // www') + '.google-analytics.com / ga.js'; var s = document.getElementsByTagName ('script') [0]; s.parentNode.insertBefore (GA, S);}) (); On a specific page, I want to track an event that auto-launches on page load. What I have for the code at the top of the page (and therefore, in a different tag than the above code):
function getFile () {if (""; Var _gaq = _gaq || []; _gaq.push (['_ trackEvent', 'Download', '& lt;% = getFileURL ()%>'])]; }} It seems that this event is not in keeping track of. I am sure that I am doing something wrong here and I can take some guesses, but it is not quite clear that I need to know what I have to change.
Two problems in your code:
- By tracking the event Are redirected first. For best results (as @AnOoostique Martin is mentioned), you want to delay the delay between event tracking and redirect.
- You got a local
_gaq GetFile () , so you are not talking to the actual Google Analytics code. Try:
function getFile () {var Href = "& lt;% = getFileURL ()%>"; If (href.length & gt; 0) {_gaq.push (['_ trackEvent', 'Download', href]); SetTimeout (function () {window.location.href = href}, 100); }}
No comments:
Post a Comment