简体   繁体   English

点击事件的Google DFP监听器事件

[英]Google DFP Listener Event for click events

I am using the following eventListener to get certain output from gpt for each available slot 我正在使用以下eventListenergpt获取每个可用插槽的某些输出

    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 现在,我想创建一个eventListener ,让我知道有人点击广告时,我尝试了以下操作

    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. 我知道我可以从DFP广告管理系统中获取报告,但我们正在尝试立即收集这些数据以及实时点击率和点击次数,而不必每次都检查报告。 Are there any suggestions that I have not tried? 有没有我没有尝试过的建议?

The short answer is - you can't (with JavaScript). 简短的答案是-您不能(使用JavaScript)。 There is no "click" action in the Google Publisher Tag (GPT). Google发布商代码 (GPT)中没有“点击”操作。

Additionally, you can't set a click event on an iFrame without access to the DOM inside the iFrame. 此外,如果无法访问iFrame中的DOM,就无法在iFrame上设置点击事件。 Unless you are using all friendly iFrames, you won't be able to. 除非您使用所有友好的iFrame,否则您将无法使用。

Another (and likely better) option is to use the DFP API . 另一个(可能更好)的选择是使用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). 另一个选择是设置您自己的重定向URL( http://example.com/path/to/dfp/redirector ),您需要在该URL之前添加广告重定向到的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]). 因此,您需要在DFP广告管理系统中制作的每个广告素材中的广告URL之前添加重定向URL(甚至不确定是否违反DFP服务条款[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. 您将无法使用JavaScript在浏览器/客户端中检测到点击,但是它将允许您在服务器中注册自己的点击。 This would require server resources on your part so make sure your hardware can handle registering the click and redirect quickly. 这将需要您自己的服务器资源,因此请确保您的硬件可以处理点击的注册并快速重定向。

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

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