Google Mobile Ads SDK App Events with Click Tracking

957 views Asked by At

We are displaying some ads in our iOS & Android applications using the Google Mobile Ads SDK. We need some parameters to make a web service call when the user clicks on the Ad and we get them using the GADAppEventDelegate, and after the web service call we present a custom screen. (so we don't want to redirect the user to a Web Page). The problem is that the Clicks are not tracked and we believe that Ad Creative might not be configured right.

<html><body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">
<html>
<head>
<script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
    function fireEvent() {
        admob.events.dispatchAppEvent("query_string", "ad_origin_key=USPS2013_iPhone_Upgraded_320x50&k_key=&acid_key=719768856&ad_image_url_key=http://USPS2013_iphone_320x50");
    }

</script>
</head>

<body>
<img src="http://pagead2.googlesyndication.com/pagead/imgad?id=CICAgIDQ59KwChABGAEyCKGNWPM-wPBl" width="320" height="50" border="0" onclick="fireEvent()"/>
</body>
</html></body></html>

I believe that in order not to be redirected to a Web Page we should make an AJAX request in fireEvent() function, something like $.get("%%CLICK_URL_UNESC%%www.example.com/ads/landingpage"); but the browser doesn't allow AJAX request to a server different of the original request server.

So how could we solve this issue, track the clicks and not navigate to a new web page?

Thanks

1

There are 1 answers

0
Chrisswong On

Hello i think this answer is a bit late but the code you quoted actually works!!

Inside your head tag of HTML of the creative

  <script src="http://media.admob.com/api/v1/google_mobile_app_ads.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script>
    // Send an event when ad loads.
    // admob.events.dispatchAppEvent("adId", "1");
    // handle your click with onClick="handleClick()"
    handleClick = function() {
      admob.log("click ad: call handleClick()"); // call a log to XCode console for debug
      // Send an event when ad is clicked.
      admob.events.dispatchAppEvent("eventName", "params"); //{action}|{action params}...

      //magic goes here
      //i think the click measure through this url 
      //and use jQuery get that send get method without callbacks
      $.get("%%CLICK_URL_UNESC%%")

    };
  </script>

You have to wait a while like 30 mins then you will see the click stats in your DFP console.