Gags
Gags

Reputation: 3829

Google Tag Manager not working on link clicks

I am facing a weird issue in Google Tag Manager as i am not able to track links with below markup

<a onclick="javascript:some_method(event, url, 'PARAM')">Test</a>

Wherever, in my code i get this kind of markup, link tracking is not working.

Is there anything special i need to do track links with javascript: notation?

Trigger Looks like as below:

enter image description here

Tag looks like as below:

enter image description here

Any assistance please?

Upvotes: 2

Views: 5566

Answers (1)

Victor Leontyev
Victor Leontyev

Reputation: 8736

You have problem with trigger condition. Click Classes - matches CSS selector - .last-td a will not work

Because Click Classes variable contains the string value of class attribute your DOM element.

You have two different ways to solve your problem:

1) You need to add some class to your a link. For example: <a onclick="javascript:some_method(event, url, 'PARAM')" class="this-is-my-last-td-link">Test</a>

Then this condition will work: Click Classes - equals - this-is-my-last-td-link

2) You can change your condition to Click Element - matches CSS selector - .last-td a without changing your markup

UPDATE

Based on discussion in chat. Your function has e.stopPropagation() inside. You need to change it with e.preventDefault()

Upvotes: 3

Related Questions