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



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 (2 New)




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 call s.prop1='foobar'; // be sure to add your vars to linkTrackVars and linkTrackEvents if call! if (s.linkType) { s.linkTrackVars='prop1'; } }



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.