Expand my Community achievements bar.

SOLVED

On Click event working, but eVar is not recording the button title

Avatar

Level 2

Hello everyone,

We've recently introduced a language translation tool to our website and I wanted to track it's usage. I have some simple event based rules setup in DTM for Activate/Deactivate and an event based rule for the menu option which was clicked, here is where I'm experiencing issues.

The event fires if I click any of the menu options, but using this.getAttribute() with an eVar does not appear to be working.

I'm using the Custom Code Editor and the event looks a little like this:

s.linkTrackVars='eVar7,events';

s.linkTrackEvents='event7';

s.eVar7=this.getAttribute('title');

s.events='event7';

Inspecting the element using browser dev tools, one of the buttons html is as follows, and I want to capture Reset in the eVar

<button class="recite-sprite-button-reset recite-reset recite-button recite-button-primary" id="recite-toolbar-button-reset" data-recite-tabbable="" title="Reset" tabindex="163"></button>

Am I using this.getAttribute correctly in the Custom Code Editor?

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

I don't see anything wrong using this.getAttribute.

I tried using similar code on my testing environment and was able to get the value for 'title' attribute into eVar.

Couple of things you can check:

> The event based in rule is firing fine on click of the button.

> Try using console.log() to troubleshooting where the issue might be.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Hi,

I don't see anything wrong using this.getAttribute.

I tried using similar code on my testing environment and was able to get the value for 'title' attribute into eVar.

Couple of things you can check:

> The event based in rule is firing fine on click of the button.

> Try using console.log() to troubleshooting where the issue might be.