2012-10-10 38 views
1
<script type='text/javascript'> 
    googletag.cmd.push(function() { 
    googletag.defineSlot('/11589435/serptest300x250', [300, 250], 'div-gpt-ad-1345189271658-0').addService(googletag.pubads()).setTargeting("TargetedKey","Targetedvalue"); 
    googletag.pubads().enableSingleRequest(); 
    googletag.enableServices(); 
    }); 
    </script> 

我在我的網站上有一個廣告位,當前正在使用Google的DFP廣告管理系統投放廣告系列。
當前客戶端有一組關鍵字,因此我們可以向他展示他自己的廣告素材。
最近,我們已經簽署了另一個客戶希望在同一廣告位功能,但是,針對一組不同的關鍵字完全DFP上的單個廣告位 - 需要投放多個有針對性的廣告系列

問題誰:我如何調整上面的一段代碼,這樣我可以看看註冊輸入的關鍵字並顯示特定廣告系列中的廣告?

'TargetedKey'=我們已註冊的客戶名稱
'Targetedvalue'=他已註冊的關鍵字。 (基本上,他有大約10個關鍵字,當用戶在我的網站上執行搜索時,我正在設法輸入'Targetedvalue'位)

p.s.在過去的2個月中,我已經選擇了DFP廣告管理系統,並且一直在爲我的組織自願管理廣告活動。我也不擅長編程。

回答

2

這更多的是與JavaScript的比DFP但是下面應該讓你測試不同的關鍵字組合...

加載這個頁面告訴項和值在URL中逗號分隔像這樣: http://yoursite.com/?key=test&values=test 1,測試2,測試3

<html> 
<head> 
    <title>DFP test</title> 

    <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"> 

     function getParameterByName(name) 
     { 
      name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 
      var regexS = "[\\?&]" + name + "=([^&#]*)"; 
      var regex = new RegExp(regexS); 
      var results = regex.exec(window.location.search); 
      if(results == null) { 
       return ""; 
      } else { 
       return decodeURIComponent(results[1].replace(/\+/g, " ")); 
      } 
     } 

     var key = getParameterByName('key'); 
     var values = getParameterByName('values').split(','); 

     googletag.cmd.push(function() { 
      slot = googletag.defineSlot('/11589435/serptest300x250', [300, 250], 'adunit').addService(googletag.pubads()).setTargeting(key,values); 
      googletag.pubads().enableSingleRequest(); 
      googletag.enableServices(); 
     }); 
    </script> 

</head> 
<body> 

    <div id="adunit"> 
     <script type='text/javascript'> 
      googletag.cmd.push(function() { 
       googletag.display('adunit'); 
      }); 
     </script> 
    </div> 

</body> 
</html> 
0

我希望你正在尋找基於某個目標關鍵字的廣告。

你能下面的方式即試圖通過在settargeting關鍵字()方法

googletag.pubads().setTargeting('tags', 'Male'); // where Male is the target keyword 
googletag.pubads().enableSingleRequest(); 
googletag.pubads().collapseEmptyDivs(); 
googletag.enableServices(); 
相關問題