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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Global area to place code that will fire for any event -- not just when a page load fires

Avatar

Level 2

17-06-2014

Today, we have many in page tagging rules which do not require a page load to fire.  I can add code to our s_code or Global rule section but those only fire when a page load is triggered.  I have a need to load variables for every event that occurs and it would be great if either the s_code or global rule section would fire for ANY rule event.  This would eliminate redundant code and make maintaining these rules easier.

2 Comments

Avatar

Level 9

24-06-2014

One thing I have done to get around this is to define s.doPlugins and put it in the global config custom code section.

 

s.usePlugins=true; s.doPlugins = function(s) { // this stuff will execute every s.t and s.tl call s.prop1='foobar'; // be sure to add your vars to linkTrackVars and linkTrackEvents if s.tl call! if (s.linkType) { s.linkTrackVars='prop1'; } }

Avatar

Level 9

19-06-2018

I fully agree with this. I also have some ideas how to implement it:

  • Have a flag in the Set Variable Action to also include global variables
  • Have a separate Action called something like "Set Global Variables"

We now did something similar to joshd's approach. We have a custom Code JS in our source repo which we add to all the rules that need them via another Set Variable Action Custom Code section.