How to pass the Data Element values to the Adobe Analytics | Community
Skip to main content
Roshanchauhan
Level 3
June 14, 2018
Solved

How to pass the Data Element values to the Adobe Analytics

  • June 14, 2018
  • 5 replies
  • 3404 views

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!

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 Stewart_Schilling

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.

5 replies

jantzen_b
Adobe Employee
Adobe Employee
June 14, 2018

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/

Roshanchauhan
Level 3
June 15, 2018

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.

In Adobe section I mapped the Data Element with eVar11

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.

Stewart_Schilling
Community Advisor
Stewart_SchillingCommunity AdvisorAccepted solution
Community Advisor
June 15, 2018

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.

Roshanchauhan
Level 3
June 15, 2018

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!

Stewart_Schilling
Community Advisor
Community Advisor
June 15, 2018

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