Expand my Community achievements bar.

SOLVED

Assigning Props and eVars to rules

Avatar

Level 6

Hi All,

When I assign props and eVars to a rule in DTM do I need to assign pagename, page url and any other data elements I want to associate to the rule or are certain props and eVars already associated?

example:

I only added those data elements that had something to do with forms however page type is in the page load rule, do I need to add it here as well?

  • Form Submit using a direct call rule
  • event 21 = form submits metric
  • prop: 
    • 18 = business email
    • 21 = page type
    • 12 = form ID
    • 19 = parent url (form is iframed onto page but from a different domain)
  • eVars:
    • 18 = business email
    • 21 = page type
    • 12 = form ID
    • 19 = parent url (form is iframed onto page but from a different domain)

thanks in advance for any help

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Let me expand on my previous post and clarify the answer. I was able to reproduce a test on my development environment today. 

Global variables set inside the tool will fire on the initial page load along with any page load rules whose conditions were met. 

 

Example:

Global Variables inside tool
prop1 = testval1

Page Load rule with no conditions
prop2 = testval2

Result:

1 Analytics beacon being fired with both prop1 and prop2.

 

Event-based and Direct Call rules firing s.tl() calls will not include these variables in their beacons without also specifying those values inside the rule.

Example 1:

Global Variables inside tool
prop1 = testval1

Page Load rule with no conditions
prop2 = testval2

Event Based rule with condition that is met
prop3 = testval3

Result:

2 Analytics beacons - the first beacon will be an s.t call with prop 1 & 2 while the second beacon will be an s.tl call with prop3

 

 

So with that said, the best practice would be to include all variables you'd like to include in the beacon on all event and direct call rules. Global variables should be set for values you wish to appear on all s.tl calls with specific page load rules modifying or appending to the global variables where necessary.

 

Hopefully, this response better answers your question. Please let me know if you still have questions or specific scenarios you'd like to run through.

 

Cheers,
Jantzen

View solution in original post

10 Replies

Avatar

Level 10

Hi,

All Adobe solutions will populate a few variables by default. These are things that make since for all customers (Things like page url, browser, time, ip, ect..). This is not unique to DTM, this will also happen when you deploy the code libraries directly to the page.

Image requests are populated in DTM in the following way:

  1. Global variables set in the DTM tool are added to the beacons
  2. Page Load rules modify the initial beacon sent on page load.
  3. Event based rules fire their own beacons with the variables that are set in those rules.

Additionally, the code contained in any given data element is not run until the data element is called by a rule or tool. 

Hopefully, these points will answer your question. If not, please try asking the question in a different way.

 

Cheers,

Jantzen 

Avatar

Level 6

so because I have page name, page url and query parameters in a global variables and page load rules then no need to add them to a specific direct call rule as they will be associated with the direct call rule?

 

in my example of the dcr for a form submit. the global variables and page load rules will be associated to the form submit so technically I only need to associate those data elements to the form submit dcr that have to do with the form only and that have not fired in the global or page load rule?

Avatar

Level 10

That is correct. If you are setting variables in the "s" object via global variables or page load rules prior to the direct call rule, you will not need to set them again in the direct call rule (unless you use the s.clearVars() function). With that said, it is best practice to include any crucial variables in the rule just in case something does not fire or a dependent rule is changed/removed. Whichever way you decide to implement, always be sure to test thoroughly in a staging environment.

 

Cheers,
Jantzen

Avatar

Level 6

could you please provide an example of "best practice to include any crucial variables in the rule just in case something does not fire or a dependent rule is changed/removed."

I just want to fully understand best practices so that I can ensure we use them at my company. Also, examples help me better understand.

 

Thanks again for all your help.

Avatar

Correct answer by
Level 10

Hi,

Let me expand on my previous post and clarify the answer. I was able to reproduce a test on my development environment today. 

Global variables set inside the tool will fire on the initial page load along with any page load rules whose conditions were met. 

 

Example:

Global Variables inside tool
prop1 = testval1

Page Load rule with no conditions
prop2 = testval2

Result:

1 Analytics beacon being fired with both prop1 and prop2.

 

Event-based and Direct Call rules firing s.tl() calls will not include these variables in their beacons without also specifying those values inside the rule.

Example 1:

Global Variables inside tool
prop1 = testval1

Page Load rule with no conditions
prop2 = testval2

Event Based rule with condition that is met
prop3 = testval3

Result:

2 Analytics beacons - the first beacon will be an s.t call with prop 1 & 2 while the second beacon will be an s.tl call with prop3

 

 

So with that said, the best practice would be to include all variables you'd like to include in the beacon on all event and direct call rules. Global variables should be set for values you wish to appear on all s.tl calls with specific page load rules modifying or appending to the global variables where necessary.

 

Hopefully, this response better answers your question. Please let me know if you still have questions or specific scenarios you'd like to run through.

 

Cheers,
Jantzen

Avatar

Level 6

awesome !! That was exactly the clarity I needed to understand fully.

Thank you again for all your help.

Scott

Avatar

Level 2

Hi Jantzen,

Very nice explanation.

But I still have one doubt.

I need to set a global variable on every beacon. That is after initial page load, when ever an Event Based rule is triggered I need to set one common prop. That means I need to set one common prop globally for each and every event beacon.

Is this possible?

Thanks in advance.

Avatar

Level 10

There isn't a global variable section that applies to s.tl() calls within the DTM UI that I'm aware of. I'm sure there is a way you could do this with a bit of custom code, but I don't haven any examples.

stewarts16448458​ - Sometimes has answers for items like this.

Avatar

Community Advisor

This sounds like a good use of the AA doPlugins function.

Take a look at the doc referenced below. 

Link Tracking Variables in doPlugins

Here's an example of the code that would go in your DTM > AA Tool > AA Custom Code (assuming that you have nothing there at present).  Also assuming that the prop that you want to set is prop10. 

s.usePlugins=true;

s.doPlugins=s_doPlugins;

function s_doPlugins(s) {

  if (s.linkType == "o" ) {

        // note: linkType is set to "o" only if you make a custom call

        // to s.tl() and set the link type to "o". Automatically tracked

        // links are set to "d" or "e" only.

        s.prop10 = "xxxxxxxxxx";

        //Make sure to add this to s.linkTrackVars

        s.linkTrackVars=s.apl(s.linkTrackVars,"prop10",",",2);

    }

}

/*

* Plugin Utility: apl v1.1

*/

s.apl=new Function("l","v","d","u",""

+"var s=this,m=0;if(!l)l='';if(u){var i,n,a=s.split(l,d);for(i=0;i<a."

+"length;i++){n=a[i];m=m||(u==1?(n==v):(n.toLowerCase()==v.toLowerCas"

+"e()));}}if(!m)l=l?l+d+v:v;return l");

/*

* Utility Function: split v1.5 (JS 1.0 compatible)

*/

s.split=new Function("l","d",""

+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"

+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a");

Avatar

Level 2

Thanks Stewart for this example, it definitely helps.