Global variables

cathyw49544988

25-10-2017

I was told that global variables are global from page to page. So if any variable will be the same for all the pages, can put in  global variables.

Then my question is, if I have a global page load rule, within this rule, I can setup some variables. Then what's the difference I setup variables in global page load rule and using global variables?

Accepted Solutions (1)

Accepted Solutions (1)

Kaushalendra

Employee

26-10-2017

The Global Variables will be set as soon as the Analytics tool loads. And hence, Page Load Rules will always fire after that.

You can refer to Load Order for Rules to get detailed information on ordering of the scripts on your page.

Answers (4)

Answers (4)

cathyw49544988

26-10-2017

Just want to further understand the load order:

1. When the global variables in analytics tool get set? I didn't see any option for this. Most likely this is fixed.

2. I can setup when to fire a rule for page load rule. ( onload, top of the page, Bottom of the page, DOM ready ). For those 4 choices, what's the order?

Thanks,

Kaushalendra

Employee

26-10-2017

Hi cathyw49544988​,

If the load order for Page Load rule is not after the Analytics tool, then Page Load Rule value will always override the value set in Analytics tool.

For example if you set eVar1 with value "Page Load" in Page Load rule with Load Order "Page Bottom" and in Analytics Tool's Global Variables you set eVar1 to "Global", the value passed in the hit will be "Page Load"

cathyw49544988

25-10-2017

For example if I setup Evar1 in the global variable and then in page load rule, I set it to something else. I assume the order should be global variable -> each rule. So in the case, the global variable should be overwrite by the page load rule value. Correct?

Kaushalendra

Employee

25-10-2017

Hi cathyw49544988​,

I believe you are comparing the usage of Global Variables in Analytics tool and setting variables in a Global Page Load rule. If so, there is not much difference in these as both will be set with all the pages.

The difference (choice) with these approach is how you want to organize this in web property. In case you want to have a granular configuration, use of Page Load rule will be preferred.