Expand my Community achievements bar.

SOLVED

this.getAttribute is not a function

Avatar

Level 3

Hi Community,

 

We recently migrated to Adobe Launch from DTM and we noticed that our links are now sending undefined values. When we did an investigation we noticed that when users click our buttons on the console we get back the following message.

Screenshot 2021-04-20 at 11.35.43.png

 

"this.getAttribute" is not a function.

I have searched the Adobe Launch best practices documents and there are no new updates around this. Please can you assist if you have experienced the same issue and managed to resolve it?

I am not sure if the new Launch TMS has stopped supporting Vanilla Javascript (raw javascript) for something else.

Thanks

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

The Data Element "cust_linkName" is set up as a custom code as follows. It looks odd because:

1) the comment line is referring to the link while this DE is not fired on a link click. In other words, if this code was fired on link click, then it would work as expected, but since it's a regular data element the "this" variable is referring to the window object.

2) the usage of setVar will not work as it writes a custom variable with the name of the existing data element

 

I assume, that this custom code was supposed to be fired inside a Rule mapped to the Mouse Click event. The code will work either in Conditions or Actions, and if you want to use the cust_linkName custom variable, delete this data element first.

 

 

//*-* Set a custom DE to hold the link name globally
var data_id = this.getAttribute('data-id');
var data_text = this.getAttribute('data-text');
var data_intent = this.getAttribute('data-intent');
var data_component = this.getAttribute('data-scope');

//*-* Set virtual Data element 
_satellite.setVar('cust_linkName', data_intent + " | " + data_component + " | " + data_text);

return true;

 

 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

The Data Element "cust_linkName" is set up as a custom code as follows. It looks odd because:

1) the comment line is referring to the link while this DE is not fired on a link click. In other words, if this code was fired on link click, then it would work as expected, but since it's a regular data element the "this" variable is referring to the window object.

2) the usage of setVar will not work as it writes a custom variable with the name of the existing data element

 

I assume, that this custom code was supposed to be fired inside a Rule mapped to the Mouse Click event. The code will work either in Conditions or Actions, and if you want to use the cust_linkName custom variable, delete this data element first.

 

 

//*-* Set a custom DE to hold the link name globally
var data_id = this.getAttribute('data-id');
var data_text = this.getAttribute('data-text');
var data_intent = this.getAttribute('data-intent');
var data_component = this.getAttribute('data-scope');

//*-* Set virtual Data element 
_satellite.setVar('cust_linkName', data_intent + " | " + data_component + " | " + data_text);

return true;

 

 

Avatar

Level 3
Hi Andrey, that actually worked. That's probably because in the scope of _satellite, "this" is not what I thought it is.