繁体   English   中英

Google DFP:使用javascript将UTM_Source传递给DFP(无需访问DFP管理员)

[英]Google DFP: Pass UTM_Source to DFP with javascript (without accessing the DFP Admin)

我正在寻找一种使用javascript从URL中获取utm_source值并将其传递给Google DFP的方法,该方法不涉及在DFP管理员中配置任何内容(例如键值定位),因为我们无权访问转到我们正在使用的特定站点的管理面板。

将不胜感激任何提示/ JavaScript代码。

使用setTargetting。 您将需要访问DFP广告管理系统仪表板中的“广告资源”标签,以创建utm代码键( 键值链接

<script>

    function getParameterByName(name, url) {
        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    }

    googletag.cmd.push(function () {
        googletag.pubads().setTargeting('utm_source', getParameterByName('utm_source'));
    });

</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM