Expand my Community achievements bar.

DTM: how to fire a rule manually

Avatar

Former Community Member

Hello,

i am using DTM and i want to trigger a rule for a special event but until now i don't find a way for implementing that.

I want to trigger a rule after a visitor spent e.g. 1 minute on a specific page. With the built-in features i didn't get it working.

 

So is there a way to recognize this special event? Furthermore i would like to know how to use the build-in function fireRule.

Perhaps i can implement a plain JS function that calls this function and i build a work-around. But honestly i'm not sure

if this is a good approach.

Maybe you guys have some ideas?

 

Kind regards

Axel

2 Replies

Avatar

Level 9

DTM does not currently have a built-in way to trigger a rule after a certain amount of time.  If you feel strongly that this is useful enough feature to have, I suggest you post the idea on ideas.omniture.com

You also mentioned _satellilte.fireRule().  I do not recommend using this. The document (link bbythewa provided) is not only not very descriptive/clear, but it is apparently outdated or outright wrong. For starters, it claims the first argument should be the rule name.  I have found that this is not the case at all. Poking at the internal code, it looks like it actually expects an object reference to the rule, located in _satellite.rules

This is as far as I poked, because once things start deviating from the documentation, it's a waste of time trying to figure out how it really works and/or work around it.  The better next step would be to report the document disconnect to Adobe and ask them for clarification on how it really works. 

But, in case you want to pursue it yourself, here is a quick function I wrote to get the Rule object by name to get you started:

 

function getRuleByName(n) { for (var r=0,l=_satellite.rules.length;r<l;r++) if (_satellite.rules[r].name==n) return _satellite.rules[r]; return false; }

Overall though, I think perhaps what you may really want to do is setup a Direct Call Rule, and then utilize _satellite.track() to trigger it. 

With a Direct Call, there is only one condition you can set, which is to specify a string value.  To trigger the Direct Call, you pass that value as the first argument to _satellite.track(). 

For example, create a Direct Call rule named "My Rule".  In the Conditions section, in the String field, put "time passed:one minute"

Then set your Adobe Analytics variables or whatever else you want to trigger, in the other sections of the rule.  Save your rule and then approve/publish it to test in live, or use staging/debug mode to test in the staging environment (pre-published)

Now as for popping it after 1 minute.. you can do this with the following code:

window.setTimeout(function() { _satellite.track('time passed:one minute'); },60000);

You can place this code in a lot of places.  For example, if you already have an existing page load rule that has no conditions, simply add this to that rule as a some javascript in the Javascript / Third Party Tags section.  Note: generally speaking, it probably doesn't matter too much whether the Trigger rule at value is for the page load rule.  Whether you have it set to output at top of page, bottom of page, on dom ready, etc.. usually it's only going to make a few milliseconds difference, depending on what all is loading on your site.  So just be aware there is that technicality if you're really striving for exactly 1 minute.  But if you are really going for exact, then you should output that directly on your page as the very first thing you can possibly output (top of head tag).  

Avatar

Employee

Hi Axel,

How were you trying to get your rule to fire?  Event-based rule? page-load rule?  And when you say the built-in feature, what do you mean?  

As for your other question, you can take a look at the documentation for the _satellite global object.  It has some methods that you can call.  Be aware that these can and do change from time to time:

https://marketing.adobe.com/resources/help/en_US/dtm/object_reference.pdf