使用Adobe Dynamic Tag Manager(DTM)时,如何编写页面级代码? [英] How can I write page level codes when using Adobe Dynamic Tag Manager (DTM)?

查看:298
本文介绍了使用Adobe Dynamic Tag Manager(DTM)时,如何编写页面级代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从静态实现迁移到Adobe DTM。有一些页面级代码,例如s.prop14 = 文章名称。但是现在,当我给出DTM的引用时,页面级代码不会触发,我在控制台中收到错误,对象s未定义。



这是什么解决方案?



谢谢!

解决方案

默认,DTM不会将全局(窗口)中的 s 对象(或在config中指定的任何其他命名空间) )范围,而DTM本身不允许你。您将不得不更新您的工具配置,以自己做,这也意味着您将不得不自己维护核心库,而不是使用受管理的Adobe功能,以绕过DTM尝试自动执行



库管理> 代码配置部分中,选择自定义,然后查看设置报表套件使用下的自定义代码。那么您将需要托管库中的在DTM(点击打开编辑器并将其复制/粘贴到那里)或在URL(自己托管文件)。在顶部(无论是在编辑器还是在文件中),您将需要在窗口名称空间下实例化对象。 AppMeasurement的示例:



window.s = new AppMeasurement();



,您可以按原样保留设置,然后更改页内的语法,然后向DTM中添加一些代码来查找。例如,在页面上的自定义代码之上,只需执行

  var s = {}; 
s.prop1 ='foobar';
// etc ..

然后在DTM中,在相同的代码编辑器(或在一个规则中?DTM中的很多地方你可以做到这一点),你可以做例如:

  for(var v在window.s){
s [v] = window.s [v];
}


I am migrating from static implementation to Adobe DTM. There are certain page level codes like for example, s.prop14=Name of Article. But now when I have given the reference of DTM, the page level codes are not firing and I am getting the error in console that object "s" is not defined.

What's the solution for this?

Thanks!

解决方案

By default, DTM does not put the s object (or whatever other namespace you specify in the config) in the global (window) scope, and DTM doesn't natively allow you to. You will have to update your tool config to do it yourself, and incidentally, this also means you will have to maintain the core library yourself instead of making use of the "Managed by Adobe" feature, to get around DTM trying to do it automatically.

In the Library Management > Code Configuration section, choose Custom and check the Set report suites using custom code below. Then you will need to either host the library either "In DTM" (click on "Open Editor" and copy/paste it into there) or "At URL" (host the file yourself). At the top (whether in editor or in file), you will need to instantiate the object under the window namespace. Example for AppMeasurement:

window.s = new AppMeasurement();

Alternatively, you can leave your setup as-is, and change the on-page syntax a bit, and then add some code to DTM to look for it. For example, above your on-page custom code, just do

var s = {};
s.prop1 = 'foobar';
//etc..

And then in DTM, in the same code editor (or in a rule.. lots of places within DTM you can do this), you can do for example:

for (var v in window.s) {
  s[v] = window.s[v];
}

这篇关于使用Adobe Dynamic Tag Manager(DTM)时,如何编写页面级代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆