Global area to place code that will fire for any event -- not just when a page load fires | Community
Skip to main content
New Participant
June 17, 2014
New

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

  • June 17, 2014
  • 2 replies
  • 4738 views

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 replies

New Participant
June 19, 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.

New Participant
June 24, 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'; } }