Environment

AppMeasurement

Question

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?

Answer

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.

      Example:

      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.

Licencia na používanie tohto diela sa poskytuje v súlade s podmienkami licencie Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Na príspevky v sociálnych sieťach Twitter™ a Facebook sa nevzťahujú podmienky licencií Creative Commons.

Právne upozornenia   |   Zásady ochrany osobných údajov online