I want to set my event_label for GUA using the value from the href or link text. Do I use a UDO or JavaScript variable? Also, when I setup the jQuery clickHandler extension, what do I select for the Set:, To: sections?

Silver Contributor
Silver Contributor
jQuery clickHandler to capture elements href of link txt into Google Universal Analytics event_label
4 REPLIES 4

I want to set my event_label for GUA using the value from the href or link text. Do I use a UDO or JavaScript variable? Also, when I setup the jQuery clickHandler extension, what do I select for the Set:, To: sections?

Tealium Employee
Hi Jon, You'll want to declare a UDO variable called event_label. Then in the extension you'll set "event_label" to "JS Code" with a value of "jQuery(this).text()" to grab the text. Depending on the HTML setup this code might change. If you need help determining the code to use to grab the value then reach out to your Account Manager and they can loop in a Solutions Engineer that can help your specific instance.

I want to set my event_label for GUA using the value from the href or link text. Do I use a UDO or JavaScript variable? Also, when I setup the jQuery clickHandler extension, what do I select for the Set:, To: sections?

Employee Emeritus

Hi Jon; To add to Dan's reply, this video might also help guide you in how to work with the Jquery extension for GUA link tracking. https://community.tealiumiq.com/t5/Tags/Video-Event-Tracking-with-Google-Universal-Analytics/ta-p/11...

I want to set my event_label for GUA using the value from the href or link text. Do I use a UDO or JavaScript variable? Also, when I setup the jQuery clickHandler extension, what do I select for the Set:, To: sections?

Silver Contributor
Silver Contributor
Thanks Dan. That worked. I have another piece of the extension I want to look into. Can I look for specific file types in the jQuery Selector like "a.doc*, a.xls*, a.zip, a.pdf, a.ppt*, a.tiff, a.mov, a.mpe*g" and from that set the event_category dynamically to the file extension using a replace function like this "jQuery(this).href.replace(/^.*\/\//,'')" ? I may need some help on the syntax for this one. Thanks, JF

I want to set my event_label for GUA using the value from the href or link text. Do I use a UDO or JavaScript variable? Also, when I setup the jQuery clickHandler extension, what do I select for the Set:, To: sections?

Tealium Employee
Hi Jon, This is a sample selector that looks to see if the anchor link's href attribute ENDS WITH pdf: {code:js} a[href$=pdf] {code} To enter multiple values use a comma to separate each selector: {code:js} a[href$=pdf],a[href$=doc] {code} To set event_category to the document type you are on the right track. Something simple like the following should do: {code:js} this.href.split('.').pop() {code} This is just split the string by '.' and returning the last array element. So the result will be "pdf" or "doc" etc.
Public