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.

Za ta izdelek je bila izdana neprenosljiva licenca za priznanje avtorstva, nekomercialno uporabo in skupno rabo pod enakimi pogoji 3.0  Objav v storitvah Twitter™ in Facebook ne urejajo pogoji pogodbe Creative Commons.

Pravna obvestila   |   Pravilnik o zasebnosti v spletu