Our website has eight links to social media. Currently, I have a separate event rule for each of these. Values are manually assigned: prop23="Facebook"
This is kind of stupid!
I want to create an event rule that will populate prop23 with part of the alt tag
alt="Facebook Logo" would become prop23="Facebook"
I have added this code as a Custom Rule Condition:
var linkName = this.getAttribute('alt');
_satellite.notify("Result: "+linkName,1);
var social= linkName.substring(0,8);
_satellite.notify("Result2: "+social,1);
return true;
It returns:
"SATELLITE: Result: Facebook Logo"
"SATELLITE: Result2: Facebook"
How can I populate prop23 with the value from my variable named "social"?
Is there a way to set the value of a Data Element in this code?
Thanks,
Ali
Solved! Go to Solution.
Hi,
In continuation to the discussion, you can also try an alternate solution for the problem through Event Rule. Please follow the below steps:
Please let me know us know if you have any questions
Thanks
Parit
The code that is in the custom code section can be added to a custom script data element. Once it is added when setting up the prop in the rule the data element name will be an option. From there you can test in staging. More information on data elements is available here: https://marketing.adobe.com/resources/help/en_US/dtm/data_elements.html
Views
Replies
Total Likes
Thanks for the reply.
The reason I put the code in the event instead of a data element is that I can't get this line to work in a data element:
var linkName = this.getAttribute('alt');
I don't know how to refer to the clicked element in a data element?
Views
Replies
Total Likes
Hi,
In continuation to the discussion, you can also try an alternate solution for the problem through Event Rule. Please follow the below steps:
Please let me know us know if you have any questions
Thanks
Parit
Thanks Parit. That's perfect!
Views
Replies
Total Likes