I want to check for an DOM element's existence, then create/set a variable based on that condition, then map this variable value to a tag. Should this be done in a JS extension? If so how would I create the data layer variable to map (or do I have to do that)?
Please have deep dive into the below related links which you are looking for,
Hope it help!
07-25-2016 02:26 AM - edited 07-25-2016 02:27 AM
Further to the answer from @Srinivasan - you can actually do this using just a set data values extension, with a condition. Then just take the output from the extension (in this case, test_trait) and map it to the required tag.
If you need to create a new data source you can add it directly from the extension, by pressing the + button in the middle of the configuration box (see below)
You could also scope the extension to the tag, if you only want that data to be available for that exact tag.
One other thing I forgot to mention, I noticed that there is no conditional configuration option available on the custom JS extension. Is there a way to isolate the custom JS to a specific URL (aside from the custom JS to detect the path, etc.)?