Expand my Community achievements bar.

Help shape the future of AI assistance by participating in this quick card sorting activity. Your input will help create a more effective system that better serves your needs and those of your colleagues.
SOLVED

How to pass the Data Element values to the Adobe Analytics

Avatar

Level 4

Hi There,

I am trying to capture the Search Type in following script code and this code has been written in Data Element in DTM. I am facing issue with that how to set condition in Rule so that i can send this data element result to the prop17.

jQuery(document).on("click mouseup touchstart",".lia-search-results-container .page-link, .lia-autocomplete-container .lia-js-autocomplete-list-item-link", function(){

if(LITHIUM.CommunityJsonObject.Page.name == "SearchPage"){

return "Search Results Page";

}else{

return "Auto Suggested Search";

}

})

Is this code need to add somewhere else (except data element)?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

I think that your jQuery is running too late to be useful. Think of the sequence this way:

1) DTM detects a click on an 'A' element and your rule is triggered.

2) In your custom condition, DTM evaluates the data element, "Search Result Position".  In this evaluation, it sets up an event listener on the specific element clicked and returns undefined.  I honestly don't know what would happen if the rule ran a second time on the same page. Anyway, It's pretty rare that you would need to directly set up event listeners in DTM or Launch. If you're interested, here's a great article on the topic - https://medium.com/launch-by-adobe/event-detection-from-dtm-to-launch-b4370cc21bb8  

Instead, try doing this.

In your rule's custom condition, write this code.

     var searchResultCount = $(this).parents(".lia-message-view-wrapper").index()+1;

     _satellite.setVar("l_searchResultPosition",  searchResultCount);

     return true;

In your AA settings:

    set eVar11 to %l_searchResultPosition%

^^^ This works by creating a data element on the fly which can be referenced later.  Be careful not to use a data element name that has been used in the UI because they cannot be set via _satellite.setVar.

View solution in original post

5 Replies

Avatar

Level 10

If the data element is populating correctly, you should be able to reference the data element using the %data_element_name% syntax  within your rule.

Here are a few resources that might help:

Getting Started with DTM: Data Elements | Adobe Blog

Marketing Cloud Help | Troubleshooting Data Elements in DTM

http://www.digitalbalance.com.au/our-blog/how-to-use-adobe-dtm-data-elements/

Avatar

Level 4

Thanks for your reply Jantzen!

I have created a Data Element to retrieve the search result position.

jQuery(document).on("click",".lia-search-results-container .page-link, .lia-autocomplete-container .lia-js-autocomplete-list-item-link", function(){

     var searchResultCount = $(this).parents(".lia-message-view-wrapper").index()+1

alert(searchResultCount);

     return searchResultCount;

  })

Created  a new event based rule for the above data element and set the condition.1508848_pastedImage_2.png

In Adobe section I mapped the Data Element with eVar111508909_pastedImage_4.png

But this not works for me, could you please help me in this how we can triggered the condition based data element in event based rule.

Avatar

Correct answer by
Community Advisor

I think that your jQuery is running too late to be useful. Think of the sequence this way:

1) DTM detects a click on an 'A' element and your rule is triggered.

2) In your custom condition, DTM evaluates the data element, "Search Result Position".  In this evaluation, it sets up an event listener on the specific element clicked and returns undefined.  I honestly don't know what would happen if the rule ran a second time on the same page. Anyway, It's pretty rare that you would need to directly set up event listeners in DTM or Launch. If you're interested, here's a great article on the topic - https://medium.com/launch-by-adobe/event-detection-from-dtm-to-launch-b4370cc21bb8  

Instead, try doing this.

In your rule's custom condition, write this code.

     var searchResultCount = $(this).parents(".lia-message-view-wrapper").index()+1;

     _satellite.setVar("l_searchResultPosition",  searchResultCount);

     return true;

In your AA settings:

    set eVar11 to %l_searchResultPosition%

^^^ This works by creating a data element on the fly which can be referenced later.  Be careful not to use a data element name that has been used in the UI because they cannot be set via _satellite.setVar.

Avatar

Level 4

Thanks Stewart!

In the same scenario I created a Data Element (written custom script to capture the "q" parameter from the URL) for Internal Site Search, and mapped this DE with eVar in Page Load rule.

But this works when page load e.g. I opened website and searched "test" redirected to the search result page and this DE capture the value and send data to the AA. When I searched 2nd time "test2", page doesn't load and this "q" parameter wasn't captured although value has changed in the URL "q" parameter.

Could you please help me in this to capture the "q" parameter directly from the URL without loading a page.

Thanks!

Avatar

Community Advisor

I think I would use the Core extension's Query String Parameter Data Element.  I also think I'd keep the Storage Duration at None to ensure that it is fully evaluated every time it is referenced

Screen Shot 2018-06-15 at 3.08.49 PM.png