Google analytics track pdf downloads

后端 未结 2 1344
暗喜
暗喜 2020-12-19 19:04

I was wondering if anyone has gotten file download and external link tracking with google analytics working.

I read here how its done http://support.google.com/googl

相关标签:
2条回答
  • 2020-12-19 19:27

    Have you tried looking at your page either in Chrome with the developer tools or Firefox & Firebug and check the console for javascript errors?

    Also, you may want to use event tracking instead of pageviews, like at http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

    In that case, your code would look something like

    <a onclick="_gaq.push(['_trackEvent', 'File', 'Download', '/pdfs/test.pdf']);" href="http://www.site.com/pdfs/test.pdf">Downland and complete a Transfer your super into Cbus form</a>
    

    Something to be aware of is that Google Analytics works by requesting a tracking pixel. If you leave the current page before the tracking pixel request has completed, you won't see the analytics data. I've had good results with variations of the following:

    <script type="text/javascript">
    function trackLink(link) {
        _gaq.push(['_trackEvent', 'Link', 'Click', link.href])
        if ("_blank" == link.target) return true;
        setTimeout('document.location = "' + link.href + '"', 150);
        return false;        
    }
    </script>
    <a onclick="return trackLink(this);" href="http://www.somesite.com/" title="External link">www.somesite.com</a>
    

    In brief, unless the link opens in a new window (`_blank" == link.target), handle going to the new URL ourselves after waiting 150 ms.

    0 讨论(0)
  • 2020-12-19 19:30

    This works for me. I'm able to find tracked file downloads in Google Analytics under the Content section. Have you tried going into Google Analytics and filtering under the Content menu section? Content -> Site Content -> Pages. Use the filter option and try searching with /pdfs/. Does that return any results for you?

    0 讨论(0)
提交回复
热议问题