Yet another article about DTM… I guess by now I can’t even get away with calling it a “mini series” anymore, can I?!
Today, I want to share a tip that came in handy a couple of weeks ago while troubleshooting a relatively complex implementation with a lot of rules.
The topic: I know that I am setting a “variable” or event somewhere — say event2. How can I find out which rule is doing that?
There are actually two ways, and I shall describe them both.
The Men Who Stare at Code
(Apologies for the non-inclusive title, I just couldn’t resist the movie title connection here.)
The easiest way to find where you’re setting a “variable” or event is to use the browser’s built-in tools. Let me show you how to do it with Chrome.
First, open the “Sources” tab in the “Developer Tools” and find the files loaded from “assets.adobedtm.com”. Under there, you’ll find one or two files that are called “satelliteLib-xyz”. Select the staging file. (I’m presuming you’re in staging)
Beautify the code (see tip #4 in David Vallejo’s article on debugging your GTM). Now you can use CTRL-F
to search for the “variable” or event you’re looking for.
From there, just scroll up very slightly, until you find the name of the rule.
That was almost too easy, wasn’t it?
Complicated
Remember that you can see all the rules in the Console?
If we can see them, then we can iterate through them, right?
Now this is ugly:
And what does it do?
Well, if you copy it into the console, then execute it, you get output like this:
Ugly, but with a huge collection of rules, this might just be useful.
The snippet works for Event-based and Direct Call Rules, but it has to be modified a little bit for Page Load Rules.
Notes
You can check what rules look like by just typing _satellite.rules
, _satellite.directCallRules
, or _satellite.pageLoadRules
into your console and inspecting the resulting objects. I’m sure you’ll find a similar way to look for eVars or props…
This is great stuff, thanks for sharing Jan!
I ended up tweaking the Direct Call rule script slightly so that it returns the name of the Rule, rather than the array location:
LikeLike
Nice touch, Eric, thanks a lot!
LikeLike
Here’s a cleaner version for PLRs:
LikeLike
And a cleaner version for EBRs:
LikeLike