Search code examples
javascriptadobe-dtmadobe-launch

Data element click URL Really not possible in Adobe Launch?


Is there really no way for data elements to return click URL? I know you can return event.element.href and setvar in RULES but I want this done through data elements for many reasons I don't have to elaborate on. Why is something as BASIC as click variables not part of the launch core extension for data elements?

Data element won't return click url. Below is one iteration I used but I've tried all kinds of ways to return click URL in a data element and none of them work. It prints to the console but the actual data element value remains undefined

jQuery(document).ready(function(){
   jQuery('a').click(function(){
     let clickHref = $(this).attr('href');
     console.log('Click URL =>', clickHref);
     return clickHref;
   });
})

Solution

  • In short, you can't because DEs don't have the context of the trigger or the event object. Another thing that doesn't have it is s code and doplugins.

    Launch is gracious enough to always give you the context of what triggered the rule in other places, however. Every rule has access to this and event. event will contain this, but this is a useful shortcut and it will give you the clicked element right away when the trigger is click. this does depend on the trigger. You would typically use this exactly how you use the {{Click Element}} in GTM.

    You can definitely still use this as a Data Element. It's useful when you want to put pieces of the clicked element in your UI rather than code. For this, you will have to set your DEs right here, in the same rule like so:

    _satellite.setVar("tempVarAttrZ", this.getAttribute("z"));

    After this, every action of this rule will have access to %tempVarAttrZ% from the UI. The getVar will work too:

    enter image description here

    Always have something marking temporary DEs to avoid using them unintendedly. Also keep in mind that if the DE is created through the Launch UI, so it pops up in the list of DEs, your setVar won't work, just pick an unused name for setting it like this.

    Finally, you often need it to be set in the first action and adding an action just to set the temporary variable is a bit too much. That's fine. I occasionally would do it through the JS conditions of the rule. It's comfy since conditions always execute before actions. And they don't allow asyncness.

    Sorry for the late reply. It's a good question, I just didn't see it here before.