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

DTM rule condition for current URL

Avatar

Level 1

Hello,

Is there a way to set the rule condition to the current URL instead of path URL? For example, I want the click event to fire on a page with /products in the current URL. If I use "path" as my condition, the click event will fire only if the NEXT page that loads has /products in the URL.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 9

I'm not sure that I understand your issue.  URL > Path (and other components) is based off the current URL (the window.location object). 

I will make a sidenote that for DTM, Path actually means location.pathname+location.search.  For this reason, I have a data element named location_pathname that returns location.pathname.  In any case, maybe there is some kind of conflict with your value vs. this?

My next guess is maybe you have timing issues because of some pushState/hashchange on your site.

But.. all of this is just throwing darts in the dark since you have not provided full details.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 9

I'm not sure that I understand your issue.  URL > Path (and other components) is based off the current URL (the window.location object). 

I will make a sidenote that for DTM, Path actually means location.pathname+location.search.  For this reason, I have a data element named location_pathname that returns location.pathname.  In any case, maybe there is some kind of conflict with your value vs. this?

My next guess is maybe you have timing issues because of some pushState/hashchange on your site.

But.. all of this is just throwing darts in the dark since you have not provided full details.

Avatar

Level 1

Your guess is actually correct. I find this issue on my site which is a single page application using pushState/hashchange rules. The timing issue I'm encountering is for a click event with /products included in the path. I want the rule to fire on any page with /products in the URL but it seems to fire only if it NEXT page has /products in the URL. Any workaround or resolution would be appreciated. Thanks!

Avatar

Level 9

The only stable way I have found to solve for timing issues with rules vs. pushState/hashchange is to have the devs explicitly call something (e.g. a Direct Call Rule) before the pushState/hashchange is executed.

Avatar

Level 10

As a side note: Officially, there isn't a way to control timing in DTM as joshd7227840​ pointed out. This is something that is addressed with Launch, by Adobe. If you haven't already looked into Launch, go ahead and visit Adobe.com/go/Launchme for a demo and to request access.