简体   繁体   中英

Using Gaq.Push to Track when a PDF is Opened

I am working on a website where there are multiple PDF's on the site. I would like to be able to track whenever a user opens a PDF, I tried doing this using the _gaq.push() method but without any luck.

Currently I have it set up like so:

All of my links are set up this way:

      <a href="docs/pdf.pdf" target="_blank" class="trackme" name="Download Specials">

and the code that sends the _gaq.push is pulled into every page:

     $('.trackme').click(function () {
        _gaq.push(['_trackEvent', 'PDFs', 'Opened', $(this).attr("name")])
     });

For some reason this has not been working and the research I have done has not really turned up any information as to what could be the issue. Does anyone know if there is a better way to do this or if its even possible?

Solved by adding

  _gaq.push(['_setAccount', 'AccountNumber']);

to the top

Your code has a syntax error. You're not closing the function:

It should be:

 $('.trackme').click(function () {
    _gaq.push(['_trackEvent', 'PDFs', 'Opened', $(this).attr("name")]);
 });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM