簡體   English   中英

帶有點擊跟蹤的Google Mobile Ads SDK應用事件

[英]Google Mobile Ads SDK App Events with Click Tracking

我們正在使用Google Mobile Ads SDK在iOS和Android應用程序中展示一些廣告。 當用戶點擊廣告並使用GADAppEventDelegate獲取廣告時,我們需要一些參數來進行網絡服務調用,並且在網絡服務調用之后,我們將顯示一個自定義屏幕。 (因此,我們不想將用戶重定向到網頁)。 問題在於沒有跟蹤點擊次數,我們認為可能沒有正確配置廣告素材。

<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>

我相信,為了不重定向到網頁,我們應該在fireEvent()函數中發出AJAX請求,例如$.get("%%CLICK_URL_UNESC%%www.example.com/ads/landingpage"); 但瀏覽器不允許向原始請求服務器以外的服務器發送AJAX請求。

那么,我們如何解決此問題,跟蹤點擊次數而不瀏覽到新網頁?

謝謝

您好,我認為這個答案有點晚了,但是您引用的代碼實際上有效!

在廣告素材HTML的頭部標簽中

  <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>

您需要等待大約30分鍾,然后您會在DFP控制台中看到點擊統計信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM