gpt4 book ai didi

javascript - 您可以在自定义页面代码上调用或使用数据元素吗?就像 GTM 中的变量

转载 作者:行者123 更新时间:2023-11-30 16:28:45 24 4
gpt4 key购买 nike

在 GTM 中,您可以使用 {{element}} 来使用您的自定义 JavaScript 标记,所以我想知道 DTM 中是否有一种方法可以在您的自定义页面代码中调用其他数据元素?

还有我正在尝试获取 eVar 1 的值,然后输出一个字符串,但还没有成功

function MyCase(){ 
var url;
var txt = s.eVar1;

switch (txt) {
case 'Forewords':
url = "forwords";
break;
case 'Executive Summary':
url = "executive-summary";
break;
case 'Educating':
url = "education";
break;
case 'Social engage':
url = "social";
break;
case 'Next generation':
url = "next-gen-retirement";
break;
case 'Conclusion':
url = "conclusion";
break;
default:
url = '';
break;
}
return url;
}
MyCase();

最佳答案

您可以使用 _satellite.getVar('data_element_name_here') 获取数据元素的值。

关于您的 eVar1 问题:从表面上看,您调用 MyCase() 并没有返回一个值,但实际上您并不是用它做任何事情。你想用它做什么?例如,您可以:

// will output the returned value in the javascript console
console.log(MyCase());

// assign the returned value to a variable called someVar
var someVar=MyCase();

// create an on-the-fly data element
_satellite.setVar('someVar',MyCase());

关于javascript - 您可以在自定义页面代码上调用或使用数据元素吗?就像 GTM 中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33683959/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com