我正在尝试在页面加载javascript后添加Google AdWords再营销列表代码 - 主要是在用户采取了特定操作后。
我从谷歌获得的标签是这样的:
<!-- Google Code for English Job Seekers -->
<!-- Remarketing tags may not be associated with personally identifiable information or placed on pages related to sensitive categories. For instructions on adding this tag and more information on the above requirements, read the setup guide: google.com/ads/remarketingsetup -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234567890;
var google_conversion_label = "abcdefghijk01234567890";
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1234567890/?value=1.00&currency_code=USD&label=abcdefghijk01234567890&guid=ON&script=0"/>
</div>
</noscript>
我可能希望稍后在页面中添加更多标签,具体取决于用户的行为,因此四个全局变量似乎是一个坏主意。有没有办法在没有全局变量的情况下触发它(可能只是用jQuery插入跟踪图像)?
答案 0 :(得分:3)
是的 - 只使用不使用全局变量的标签的异步版本:https://developers.google.com/adwords-remarketing-tag/asynchronous/
所以你需要在你的喜欢中包含异步脚本:
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion_async.js" charset="utf-8"></script>
然后,当您需要触发它时,只需根据需要调用全局范围内可用的新功能
<script type="text/javascript">
/* <![CDATA[ */
window.google_trackConversion({
google_conversion_id: 1234567890,
google_conversion_label: 'abcdefghijk01234567890',
google_custom_params: window.google_tag_params,
google_remarketing_only: true
});
//]]>
</script>
确保每次使用新信息调用时更新window.google_tag_params(或仅使用单独的对象或对象文字)。
希望有所帮助。