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.

本产品经 Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License 许可  Twitter™ 与 Facebook 中的内容不在 Creative Commons 的条款约束之下。

法律声明   |   在线隐私策略