Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

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

Avatar

Level 2

6/17/14

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

6/24/14

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

6/19/18

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.