this.getAttribute is not a function | Community
Skip to main content
keithb81089125
Level 2
April 20, 2021
Solved

this.getAttribute is not a function

  • April 20, 2021
  • 1 reply
  • 3949 views

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.

 

"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

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Andrey_Osadchuk

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;

 

 

1 reply

Andrey_Osadchuk
Andrey_OsadchukAccepted solution
Level 10
April 21, 2021

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;

 

 
keithb81089125
Level 2
April 21, 2021
Hi Andrey,