Mobile app version of vmapp.org
Login or Join
Cooney921

: Create a macro for links' href attribute in Google Tag Manager In Google Tag Manager, I'd like to track with an event label in Google Analytics the clicked links href attribute. On our front

@Cooney921

Posted in: #GoogleAnalytics #GoogleTagManager

In Google Tag Manager, I'd like to track with an event label in Google Analytics the clicked links href attribute.

On our front page there is a main Call-To-Action section that actually has 3 links. I'd like to track each one.

1) The base Google Universal Analytics (GAUA) tag already exists on all pages.

2) I created a new GAUA tag with the same tracking ID as the base tag.

3) I have specified the following:


Track type: event
Category: Some Category
Action: Some Action
Label: Href attribute


Within the event setup, when I select "New Macro" there is an option for DOM, which I thought sounded right but it requires the elements ID. On this site those links do not have an ID attribute.

I tried simply using the CSS selector for the element: a.button.blue-button and then, under Attribute Name I wrote "href".

But it's not working. This was for the label of the event.

How would I create a macro to record the clicked links href attribute?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cooney921

2 Comments

Sorted by latest first Latest Oldest Best

 

@Bethany197

You should open a Tag and defined it as "Event"
You can put whatever you want in the category/action/label. I recommend :
Category = Page url
Action = Click Url
Label = Element text

Now you need to create a trigger that will fire every time somebody click on your call to action. I suggest you choose a trigger - "Click on links"
choose :"some links" and define that ONLY when clickURL equale the link you want to track.

10% popularity Vote Up Vote Down


 

@Vandalay111

Google Tag Manager does not automatically listen to clicks. You need to tell it to do that by triggering an "Event Listener" type tag.

Then you can create a rule based on the event 'gtm.linkClick' and get the href using the 'element url' predefined macro.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme