Google Analytics and Auto Lists

I am trying to set up Google Analytics Event Tracking our website. I’ve identified the code that needs to be placed into the a tag , so that we can track PDF and Video downloads.

code: Play

I can place this code into the rich text widgets manually, however, I need to try to find a way to add this code to the documents or the a tag that are being pulled into an auto list.


Thanks so much for your time!

Hi Kristy,

Are you looking to add this code to the a tags generated by a File Auto List? Or are these PDF and Video download links appearing within the summary of a standard Page Auto List? Thanks.

The first one. I am looking to add a snippet of code to each “a” tag, each snippet will not be the same.

Hi Kristy,

For this function to be triggered when a user clicks on a link in a File Auto-List, you could add a jQuery click function to all a tags contained within the auto list. To do this, first add a CSS class to your auto list’s list items by editing the widget through the Style tab and using the “CSS file list class” input field, and then include this code below in one of your page or template’s meta-data insertion points:

$('ul.myList a').click(function() { <br />
return _gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\’s First Birthday']); <br />
<br /> }); <br /> </script>```   
In this example, “myList” is the CSS class name added to the widget. Let me know if this works.

Each item displayed in the File Auto List will need to have different trackEvent descriptors.

Will this solution allow me to do this? Will I need to create a jQuery click function for each?


My solution may not be very feasible, in this case. Not only would you need to create new functions for each link, but you would also need to use advanced pseudo-selectors to target the each link individually, and furthermore you would need to update this code anytime you added files to the auto-list.

Someone with more knowledge of Google Event Tracking may know of a better solution, but it seems to me, if adding this code to your links is a high priority, then you may want to relocate these links from the File Auto-list into a plain HTML widget so that you can add the onClick events into the anchor tags manually.