GTM - get href value inside custom html tag

Ask_SO

I have below anchor tags in my site and I am tracking data in Google Analytics using GTM.

I have created a custom html Tag in GTM which sends user data to GA. This tag will fire when trigger with Click_ID matches 'Nav_Link1' or 'Nav_Link2'. Inside my GTM tag, I need to get corresponding href value which matches with id. If I click first link I need to capture, first links href value and same as for all the anchor tags.

How to achieve this in GTM?

<a id="Nav_Link1" href="/External/UserData">UserData</a>
<a id="Nav_Link2" href="/External/OwnerData">OwnerData</a>
kgrg

The easiest way for this is to enabel Click URL within built-in variable, which does exactly the same thing, what you need. You can then refer to it as {{Click URL}}.

Although at your current use case it might not be a problem, but your trigger should be preferably Click - Just Links type, so that the actual clicked element would not be any other elements within the a tag, which might not provide value for the Click URL variable.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get a value from inside an href in the HTML structure

How to get value of a custom attibute inside a <option> tag using JAVASCRIPT

JSON value inside href tag in react

How to get dynamic variable's value inside a HTML tag

How to get text inside <a href> tag without the link in href, with Puppeteer

How to get select box value in a href tag

Get local href value from anchor (a) tag

Get href value while clicking li tag

Get href value from anchor tag with bash

How to get href value of anchor tag if it has image tag in it

Get Xpath for href from a tag based on span tag value

Inject custom tag into Microsoft Clarity with GTM

Scrapy, get a href from inside a H3 tag?

How to get the href from an <a> tag inside a <div> by text using beautifulsoup?

Get a value of span tag HTML

Select a tag with custom data value and change its href with jquery

Changing text value inside of a tag in HTML with jquery

return value inside html tag with beautifulsoup

Get href tag inner text from html (html agility pack)

How to get the value of a specific tag inside XML

How to get attribute value inside li tag?

How to get html in python inside #document tag?

Get HTML inside div tag Python Scrapy

how to get literal array value stored inside script tag on html page using javascript or protractor

How get a custom tag with html agility pack?

How to get a certain table tag from div tag inside of html?

Using value of JavaScript inside video HTML tag inside of .setContent() in Leaflet

Python/Selenium - Can't get HREF value of a tag

How do I get "href" value of an "a" tag using scaper in Rust?