Creating a Custom Clicked Element by Link Extension

madraxsam
Participant

We have hundreds of eCommerce product pages with different types (.pdf, .skp, .doc, .dwg, etc.) of support documentation on each. I want to set up link click event tracking to track when each type of a file is downloaded. 

 

I'm trying to follow this documentation: https://knowledge.hubspot.com/articles/kcs_article/events/create-clicked-element-events#manually-cre...

 

Tracking by ID and Class is too broad. I believe/hope I can do it using a jQuery selector. I just don't know what I need to enter as the jQuery selector when setting this up in HubSpot to track the links properly. Can I track by something along the lines of link contains .dwg and what would I use?

Would this be what I use: a[href$=".pdf"] to rack .pdf link clinks? 

 

Note: These pages and files are not hosted on HubSpot, but HubSpot tracking is on the page. 

 

Here is an example of the code for the link.

<a href="https://www.madrax.com/media/catalog/product/u/x/ux238-lb-ig_sf__1.dwg" target="_blank" title="CAD">
UX238-LB (DWG) </a>

 

 

1 Reply 1
IsaacTakushi
HubSpot Employee

Hi, @madraxsam.

 

Apologies for the delayed response.

 

Yes, you're right on track! This selector worked for me:

a[href$=".gif"]

jQuery Selector.jpg

Isaac Takushi

Associate Certification Manager
0 Upvotes