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

Can you call or use a Data Element on a Custom Page Code? like the variables in GTM

在 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() 并且它 returns 是一个值,但您实际上并没有做任何事情用它。你想用它做什么?例如,您可以:

// 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());