点击时让Google AdSense广告执行功能 [英] Making a Google AdSense ad to do a function when clicked

查看:124
本文介绍了点击时让Google AdSense广告执行功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我试图在Google AdSense广告中添加标签,当有人点击广告时,广告就会调用该功能。



我试着将标签但由于某种原因,它只会影响广告周围的内容,而不会影响广告文字/图片本身。



这与获得更多点击次数无关。它只是简单地登录一个文本文件,有多少人点击了它。



这是我到目前为止所尝试的,并且只对空间有效

 < div id =adonClick =return alert('Hello');> 
< script type =text / javascript>
google_ad_client =ca-pub-0000000000000;
google_ad_slot =000000000000;
google_ad_width = 250;
google_ad_height = 250;
< / script>

< script type =text / javascript
src =http://pagead2.googlesyndication.com/pagead/show_ads.js>
< / script>
< / div>

有人可以帮我解决这个问题吗?

解决方案

AdSense广告已加载到iFrame中。由于沙箱安全问题,您无法通过冒泡捕获来自它们的点击。您也不能通过JavaScript触发广告点击。



然而,您可以做的是跟踪页面焦点,以确定某人是否已点击并猜测点击广告。



使用本教程,我已经完成了这项工作,并取得了相当不错的成绩:

http://www.bennadel.com/blog /1752-Tracking-Google-AdSense-Clicks-With-jQuery-And-ColdFusion.htm



这不是100%准确的,但它是最好的你可以做。基本上,当您将鼠标悬停在iFrame上时,它会设置一个状态来监视焦点丢失到主窗口。如果发生这种情况,它会假定文档失去焦点,因为用户点击了iFrame。


Okay, I'm trying to put tags around a Google AdSense ad that will call a function when someone clicks the ad.

I've tried to put tags around it but for some reason it's only taking effect for what's around the ad, not the ad text/picture itself.

This has nothing to do with gaining more clicks or what ever, it's just gonna simply log in a text file how many people have clicked it.

Here's what I've tried so far, and it only takes effect for the space around the ad.

        <div id="ad" onClick="return alert('Hello');">
<script type="text/javascript">
google_ad_client = "ca-pub-0000000000000";
google_ad_slot = "000000000000";
google_ad_width = 250;
google_ad_height = 250;
</script>

<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

Can someone help me or is this even possible?

解决方案

AdSense ads are loaded in an iFrame. You can't capture clicks from them by bubbling, due to sandbox security issues. Nor can you trigger clicks on an ad via JavaScript.

What you can do, though, is track page focus to determine whether someone has clicked off and "guess" if they clicked the ad.

I've done this before with pretty darn good results, using this tutorial:

http://www.bennadel.com/blog/1752-Tracking-Google-AdSense-Clicks-With-jQuery-And-ColdFusion.htm

It's not 100% accurate, but it's the best you can do. Basically, when you mouseover the iFrame, it sets a state to watch for loss of focus to your main window. If that happens, it assumes the document lost focus because the user clicked on the iFrame.

这篇关于点击时让Google AdSense广告执行功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆