dousi1906 2017-02-20 14:18
浏览 77
已采纳

点击活动的Google DFP广告管理系统侦听器事件

I am using the following eventListener to get certain output from gpt for each available slot

    googletag.pubads().addEventListener('slotRenderEnded', function(event) {
        gptForForm[count] = [ event.creativeId, event.lineItemId, event.size[0] + 'x' + event.size[1] ];
        count++;
    });

Now I want create an eventListener that will let me know when someone clicks on an ad, I tried the following to no avail

    googletag.pubads().addEventListener('click', function(event) {
        console.log('this lineItemID: '+event.lineItemID+', size: '+event.size[0]+','+event.size[0]+' clicked!!');
    });";

I know I can get a report from DFP but we are trying to collect this data right away and real-time CTR and Clicks without having to check the report every single time. Are there any suggestions that I have not tried?

  • 写回答

1条回答 默认 最新

  • dongyan1974 2017-02-20 20:36
    关注

    The short answer is - you can't (with JavaScript). There is no "click" action in the Google Publisher Tag (GPT).

    Additionally, you can't set a click event on an iFrame without access to the DOM inside the iFrame. Unless you are using all friendly iFrames, you won't be able to.

    Another (and likely better) option is to use the DFP API.

    Another option is to set up your own redirection URL (http://example.com/path/to/dfp/redirector) that you would need to prepend to the URL the ad needs to redirect to (your redirector would register a click then redirect to the ad's URL). So you would need to add your redirection URL before the ad's URL in every creative you make in DFP (not even sure if this would be a violation of the DFP terms of service [TOS]). You would not be able to detect a click within the browser/client using JavaScript but it would allow you to register your own clicks in a server. This would require server resources on your part so make sure your hardware can handle registering the click and redirect quickly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊