开发者

track download with asynchronous google tracking doesn't load google's gif

开发者 https://www.devze.com 2023-01-14 14:55 出处:网络
I tracking a download of a pdf with this code: _gaq.push([\'_trackPageview\', trackLink]); When I check the net console (firebug), it tries to load the google gif for tracking, bu开发者_JAVA技巧t

I tracking a download of a pdf with this code:

_gaq.push(['_trackPageview', trackLink]);

When I check the net console (firebug), it tries to load the google gif for tracking, bu开发者_JAVA技巧t doesn't get loaded, see screendump here: http://screencast.com/t/MWVkZTU0OD

If I copy the url for the tracker and call it directly in the browser, it works:


The root of the problem maybe in that the request to the google gif is interrupted because the browser navigates to the different url (download). Try delaying the download in this way:

<a href="PDF" onclick="that=this; _gaq.push(['_trackEvent','click', 'download', 'pdf'); setTimeout(function(){location.href=that.href;},200);return false;">Download pdf</a>

This will let some time for the analytics script to request the utm.gif.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号