Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: Kase en 26 Junio 2013, 09:36 am



Título: detectar clic en adsense
Publicado por: Kase en 26 Junio 2013, 09:36 am
quiero detectar cuando mis usuarios hacen clic en adsense (ya se que adsense te dice cuantos clics hay, o analitics)  pero quiero destacar los post donde mas usuarios hacen clic de manera automatica.

Código
  1. <script type="text/javascript" src="http://static.bloqueomental.com/bloqueomental/static/jquery.js"></script>
  2. <script>
  3. $(document).ready(function() {
  4.  
  5. // I am a flag that will determine if the user is
  6. // currently mousing over a Google AdSense.
  7. var isOverGoogleAd = false;
  8.  
  9. // When a user mouses over a Google AdSense iFrame, we
  10. // want to track that activity. This way, when the
  11. // current window blurs, we can guesstimate as to
  12. // whether or not the window-blur was due to the user
  13. // clicking the Google ad.
  14. //$( "iframe[ id *= google ]" )
  15. $( "#myframe" )
  16. .mouseover(
  17. function(){
  18. isOverGoogleAd = true;
  19. }
  20. )
  21. .mouseout(
  22. function(){
  23. isOverGoogleAd = false;
  24. }
  25. )
  26. ;
  27.  
  28. // Now that we are tracking the mouse movements over
  29. // the Google AdSense, let's track the window's blur
  30. // event to see if we can guesstimate the AdSesnse
  31. // usage.
  32. $( window ).blur(
  33. function(){
  34. // Check to see if the user was over a Google
  35. // AdSense ad when the window was blurred.
  36. if (isOverGoogleAd){
  37.  
  38. // Because the user was mousing over a
  39. // Google AdSense iFrame when the window
  40. // was blurred, it is reasonable to
  41. // estimate that the blurring is due to
  42. // the user clicking one of the ads.
  43. alert('click');
  44. }
  45. }
  46. )
  47. // Focus the window by default.
  48. .focus()
  49. ;
  50.  
  51. });</script>
  52.  

tengo este codigo que en general detecta    iframes.. el problema es que el boton de like de facebook tambien es un iframe... alguien se le ocurre una solucion? :S


Título: Re: detectar clic en adsense
Publicado por: engel lex en 26 Junio 2013, 09:51 am
no entiendo... solo tienes que leer el iframe del adsense y listo -.-


Título: Re: detectar clic en adsense
Publicado por: #!drvy en 26 Junio 2013, 11:23 am
Ese código no detecta todos los iframes.. solo detecta el iframe con id "myframe" o el que tu le indiques en la linea 15.

Saludos


Título: Re: detectar clic en adsense
Publicado por: Kase en 26 Junio 2013, 19:57 pm
muchas gracias drvy   efectivamente funciona como dijiste...    es que el codigo no es mio n__nU   la verdad no se donde lo encontre :S  y no me abia percatado de ese detalle #myframe  y pensandolo bien.. enrrealidad detecta cualkier elemento  myframe

<div id=myframe> <codigo adsense que genera un iframe ></div>

perdon por la molestia, que tonto fui al leerlo >__<


Título: Re: detectar clic en adsense
Publicado por: engel lex en 26 Junio 2013, 20:00 pm
para que veas que ni lees los códigos, lee entre la linea 9 y 14 -.- una cosa es no ser tuyo otra cosa es "copié este código, y lo publicaré en el foro para que me digan como se usa" -.-