Highlighted

Link tracking to send an event to GA

Rookie Contributor

Hi there,

I want to add event tracking to some download links on a page. Every download link on the page has the "document-link" class. Now I want the event action to be the document type, for instance pdf and the event label to be the url path of the file, so the href of the clicked link.

 

I have created an onHandler extension with jQuery selector: a.document-link, which triggers on mousedown, Tracking event is set to "link" and than I have the event attributes as follows:

event_category set to Text: Download
event_action set to JS code: ... this is where I need to get the file type
event_label set to JS code: ... this is where I need to get the link or file name

Thank you very much in advance!

2 REPLIES 2
Highlighted

Link tracking to send an event to GA

Employee Emeritus

Hello @TheReference. Does this document help you at all?

https://community.tealiumiq.com/t5/Tags/Google-Universal-Analytics-Tag-Advanced-Mapping/ta-p/11985#e...

Please let me know! Thank you. 

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.
Highlighted

Link tracking to send an event to GA

Gold Contributor
Gold Contributor
@TheReference

For capturing the download link when user tries to click on the link, we can go ahead with the pretty straight forward implementation with the JavaScript extension

Example below:

$(".a.document-link").click(function() {

event variables here

call utag.link();

});

Thats it. Hope this helps!