When multiple calls are triggered on a page, variables and events set with the first call are also being sent in the consecutive calls. How to ensure that variables and events do not prevail/persist beyond one analytics server call?


On a page, the state of the analytics object is not reset. Hence, if multiple calls are triggered they all use the same object. It results in consecutive calls sent with the same variables and events.

You can prevent it by using any of the following approaches (as applicable):

  1. ClearVars: Clear the variables/events in the 's' analytics object by using clearvars() function. You can also use it for managing state in Single Page Apps.

  2. Variable Overriding: You can use Variable overrides to change variables/events for a single analytics call.

    You can implement it in two ways:

    1. Using Inline Variables: In s.tl() call, you can pass the variables directly as fourth parameter.


      s.linkTrackVars = "eVar1,events";
      s.linkTrackEvents = "event10";
      s.tl(this, "o", "My Link", {"events": "event10", "eVar1" :"12345"}, null);
    2. Using Explicit Object: You can pass an object in s.t() or s.tl() call as shown in examples.

Dette arbejde har licens under en Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Opslag på Twitter™ og Facebook er ikke omfattet af vilkårene for Creative Commons.

Juridiske meddelelser   |   Politik for beskyttelse af personlige oplysninger online