Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Firing DTM rules based on datalayer values

sidh19884490
Level 3
Level 3

Hi guys,

The search is on my site doesn't generate a pageview. When a search is performed on the site, the search parameters are passed on to the digitalData datalayer, for example, when a search is successful, onsite search = success is passed on to the digitalData datalayer without using _satellite.track. Can I fire a DTM rule based on the when the digitalData datalayer  'onsite search = success'?  I need this quite urgently, so any help quickly would be much appreciated.

Many thanks

Sid

1 Accepted Solution
ParitMittal
Correct answer by
Level 10
Level 10

Hi Sid,

We offer since apology for the delayed response.

For the use case discussed above, We would recommend to use Direct Call based rules. Direct call rules are ideal for situations where you want to tell dynamic tag management exactly what is happening. Also, they are ideal when dynamic tag management cannot detect an event in the DOM, such as with Adobe Flash or Ajax call. For more information about Direct Call Based rules  Please see the following link .

https://marketing.adobe.com/resources/help/en_US/dtm/t_rules_direct_conditions.html

Thanks & Regards

Parit Mittal

View solution in original post

10 Replies
Rahsing
Level 8
Level 8

Hi Sid,

You can use the 'data element value' option under the conditions and then select the relevant data element to fire your rule based on datalayer values.

Kind Regards

Rahul

Cleve_Young
Level 2
Level 2

In some similar scenarios, which in our case used Ajax to make the search updates, I've used DTM to include some jQuery to watch for the Ajax Success/Complete event. When that happens and the correct criteria is met it fires a direct call rule. Ideally you would have the developers include that direct call in the regular search code, but as that is not always feasible this works as a viable alternative for me.

sidh19884490
Level 3
Level 3

Hi Cleve,

Thanks for sharing the information. Similarly, for my case, I think I need to add some code to listen to the change in the datalayer values after the page loads and then fire the direct call rules when the condition in the datalayer value matches. But I'm not good with the code and can't find anything in the internet, which would allow me to do this in DTM. Any suggestion?

Regards

Sid

sidh19884490
Level 3
Level 3

Hi Rahul,

Thanks. Would it be an event based rule based on the data element values in the rule condition? If so, what would be the element tag or selector as it doesn't seem I can leave this field empty. Basically, is there any way to fire the rule without using this field.

Page load rule doesn't work as the search isn't generating a page load.

Regards

Sid

Rahsing
Level 8
Level 8

Hi sid,

Technically, since this is a search result that you are trying to track, you would most likely need the search to generate a page load so as to use it in a rule (since you have no other event you can associate it with).

The element tag or selector is used to specify the element in your website you are tracking

Could you give me some info on how you're defining a search = success (if possible with a snapshot)?

Regards

Rahul

Rahsing
Level 8
Level 8

Sid,

If you're unable to figure out how to write a direct call rule for your requirement, feel free to reach out to customer care and they can help you out with it.

Let me know if you're still unable to resolve this problem.

Regards

Rahul

Cleve_Young
Level 2
Level 2

I was guessing that your page may be using some form of Ajax to return the Search results, as that is fairly common. If so then you may be able to use $( document ).ajaxComplete(function(){}) to watch for that. I don't know if there is a specific code to watch for a datalayer value to change; as an alternative you could put in some code using setInterval() to check that value every X seconds/milliseconds after the "search" button is clicked, and if it changes then fire the Direct Call rule and then clearInterval() to stop the checker. 

sidh19884490
Level 3
Level 3

Sure. Please see attached the datalayer values as a search is performed.

Rahsing
Level 8
Level 8

Hi Sid,

You would need to use direct call rules in this case (since your search doesn't generate a pageload).

Regards

Rahul

ParitMittal
Correct answer by
Level 10
Level 10

Hi Sid,

We offer since apology for the delayed response.

For the use case discussed above, We would recommend to use Direct Call based rules. Direct call rules are ideal for situations where you want to tell dynamic tag management exactly what is happening. Also, they are ideal when dynamic tag management cannot detect an event in the DOM, such as with Adobe Flash or Ajax call. For more information about Direct Call Based rules  Please see the following link .

https://marketing.adobe.com/resources/help/en_US/dtm/t_rules_direct_conditions.html

Thanks & Regards

Parit Mittal

View solution in original post