将查询字符串传递到Google Publisher标签

3
我需要将当前URL中的查询字符串传递给GPT(Google Publisher Tag),以便在页面加载时调用DFP。例如,如果这是URL: http://example.net/article/100-days.html?c=xyz 我需要将c=xyz插入为键值。我有50多组这些c=查询字符串,并且需要GPT调用针对出现的任何字符串(无论是c=xyz还是c=abc等)的广告。
<head>

 <script type="text/javascript">
   var googletag = googletag || {};
   googletag.cmd = googletag.cmd || [];
   (function() {
     var gads = document.createElement("script");
     gads.async = true;
     gads.type = "text/javascript";
     var useSSL = "https:" == document.location.protocol;
     gads.src = (useSSL ? "https:" : "http:") + "//www.googletagservices.com/tag/js/gpt.js";
     var node =document.getElementsByTagName("script")[0];
     node.parentNode.insertBefore(gads, node);
    })();
</script>

 <script type="text/javascript">
   googletag.cmd.push(function() {
   googletag.defineSlot('/6355419/Travel/Europe/France/Paris',[300, 250], "banner1"); // adds the first slot with it's own slot level custom targeting

   googletag.pubads().setTargeting("c","xyz"); // adds custom targeting that applies to the entire page - i.e. all the slots on the page.

     googletag.enableServices();
   });
 </script>
</head>

我认为这需要一个获取函数,但我不确定在JS中最有效的方法是什么。

1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接