清除变量Adobe Analytics(DTM)[重复]

时间:2022-06-01 15:50:25

This question already has an answer here:

这个问题在这里已有答案:

On DTM, in every pageViews and events I've included these code lines to clear variables in 'Javascript / Third Party Script' box.

在DTM上,在每个pageViews和事件中,我都包含这些代码行来清除“Javascript / Third Party Script”框中的变量。

var s = _satellite.getToolsByType('sc')[0].getS();
s.clearVars();

I'm having problems trying to clear variables in the following case: When there's an onclick event that redirect to another page, this code always fails and copy its variables(event variables) in the pageView hit.

我在以下情况下尝试清除变量时遇到问题:当有一个重定向到另一个页面的onclick事件时,此代码总是失败并在pageView命中复制其变量(事件变量)。

I enroll an picture with an example. Variables copied among hits

我用一个例子注册了一张照片。在命中之间复制的变量

How can I solve this problem? Thank you!

我怎么解决这个问题?谢谢!

2 个解决方案

#1


0  

If you are using an event-based rule to capture the onClick event, DTM will automatically set linkTrackVars and linkTrackEvents to "None". This should prevent the previous page view events from cascading to the next call.

如果您使用基于事件的规则来捕获onClick事件,DTM将自动将linkTrackVars和linkTrackEvents设置为“None”。这应该可以防止先前的页面视图事件级联到下一个调用。

However, if you're sending page view data (s.tl()) with the onClick, then yes, your previous events could be included.

但是,如果您使用onClick发送页面视图数据(s.tl()),则可以包含您之前的事件。

I would suggest using event-based rules for the onClick events if possible so only your specific events are set.

如果可能的话,我建议对onClick事件使用基于事件的规则,以便只设置您的特定事件。

Hope this helps.

希望这可以帮助。

#2


0  

Try this:

function ClearVars() {
    for (var i = 0; i < 100; i++) {
        s['prop' + i] = '';
        s['eVar' + i] = '';
        if (i <= 5)
            s['hier' + i] = '';
    }
    s.list2 = '';
    s.list1 = '';
    svarArr = ['pageName', 'channel', 'products', 'events', 'campaign', 'purchaseID', 'state', 'zip', 'server', 'linkName'];
    for (var i = 0; i < svarArr.length; i++) {
        s[svarArr[i]] = '';
    }
}

ClearVars();

#1


0  

If you are using an event-based rule to capture the onClick event, DTM will automatically set linkTrackVars and linkTrackEvents to "None". This should prevent the previous page view events from cascading to the next call.

如果您使用基于事件的规则来捕获onClick事件,DTM将自动将linkTrackVars和linkTrackEvents设置为“None”。这应该可以防止先前的页面视图事件级联到下一个调用。

However, if you're sending page view data (s.tl()) with the onClick, then yes, your previous events could be included.

但是,如果您使用onClick发送页面视图数据(s.tl()),则可以包含您之前的事件。

I would suggest using event-based rules for the onClick events if possible so only your specific events are set.

如果可能的话,我建议对onClick事件使用基于事件的规则,以便只设置您的特定事件。

Hope this helps.

希望这可以帮助。

#2


0  

Try this:

function ClearVars() {
    for (var i = 0; i < 100; i++) {
        s['prop' + i] = '';
        s['eVar' + i] = '';
        if (i <= 5)
            s['hier' + i] = '';
    }
    s.list2 = '';
    s.list1 = '';
    svarArr = ['pageName', 'channel', 'products', 'events', 'campaign', 'purchaseID', 'state', 'zip', 'server', 'linkName'];
    for (var i = 0; i < svarArr.length; i++) {
        s[svarArr[i]] = '';
    }
}

ClearVars();