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

DTM rule condition for current URL

kevinm1613195
Level 1
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
joshd7227840
Correct answer by
Community Advisor
Community Advisor

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
joshd7227840
Correct answer by
Community Advisor
Community Advisor

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

kevinm1613195
Level 1
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!

joshd7227840
Community Advisor
Community Advisor

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.

jantzen_belliston-Adobe
Community Manager
Community Manager

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.