簡體   English   中英

Google Analytics V4廣告系列衡量標准測試不起作用

[英]Google Analytics V4 Campaign measurement Testing is not working

我開始使用Google Analytics V4實施廣告系列衡量,參考鏈接https://developers.google.com/analytics/devguides/collection/android/v4/ 遇到https://developers.google.com/analytics/solutions/testing-play-campaigns中提到的經過測試的Campign Measurement時遇到的問題。 每次我的日志顯示“未找到廣告系列數據”

我將google Play服務(版本:18)導入我的工作區並在我的項目中引用它

在我的清單文件中添加了以下行

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>

<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.analytics.globalConfigResource"
    android:resource="@xml/global_tracker" />

以及代碼下面

<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
  android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

后來在res-> xml下創建了global_tracker.xml文件。 下面是我的xml文件

    <?xml version="1.0" encoding="utf-8" ?>

<resources xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="TypographyDashes"
>
  <integer name="ga_sessionTimeout">300</integer>

    <!-- Enable automatic Activity measurement -->
    <bool name="ga_autoActivityTracking">true</bool>
    <bool name="ga_debug">true</bool>
    <string name="ga_logLevel">verbose</string>
    <string name="ga_dryrun">true</string>

    <!-- The screen names that will appear in reports -->

    <!--  The following value should be replaced with correct property id. -->
    <string name="ga_trackingId">UA-xxxxxxx-1</string>
</resources>

已使用我的跟蹤ID替換了跟蹤ID

在測試廣告系列衡量時,我首先通過adb install將我的應用安裝到我的設備上(Moto G(4.4.2))。 確保應用程序未運行並廣播上述鏈接中提到的意圖。 我在廣播意圖時獲得了成功記錄。

意圖

E:\xxxxxxx\adt-bundle-windows-x86_64-20140321\sdk\platform-tools
>adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <My Package name>/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testsource"

響應:

Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=<My Package name>
>/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) }
Broadcast completed: result=0   

當我打開我的應用程序時,我總是得到“ I / GAV2(7342):線程[GAThread,5,main]:找不到廣告系列數據。 ”我的日志中出錯。

可以請有人告訴我為什么我沒有獲得廣告系列數據? 我哪里錯了。

此外,當我使用GAV4時,為什么它在日志中顯示“GAV2”

GA日志:

07-09 12:59:26.542: W/GAV2(20502): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch.
07-09 12:59:31.568: I/GAV2(20502): Thread[GAThread,5,main]: No campaign data found.

注意:這是我第一次使用Google Analytics。 由於我想先檢查我是否收到廣告系列數據,因此我沒有對GA實施任何跟蹤器

編輯:當我手動觸發廣播意圖按鈕時,單擊我的應用程序。 當我重新啟動我的應用程序時,我能夠看到“Campaign found”日志。 但是,如上所述,使用“adb shell”命令觸發意圖時也不會發生同樣的情況。 我懷疑可能是意圖沒有達到我的設備。 有沒有辦法找到是否收到意圖?

請幫忙

1>對於初學者你可以混合兩件事。 此鏈接適用於Google Analytics-v4 https://developers.google.com/analytics/devguides/collection/android/v4/ ,此鏈接https://developers.google.com/analytics/solutions/testing-play-campaigns不適用於v4(頁面太舊,此頁面發布時沒有GAV4。

2>檢查物理設備(Google Play服務)版本並將其更新為5.0(如果尚未完成)。

3>你不需要下面提到的鍋爐板代碼。 我認為這是針對GAV3而不是GAV4

<service android:name="com.google.android.gms.analytics.CampaignTrackingService"/>
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
  android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>

為了更清晰的代碼檢查此鏈接。 未找到廣告系列數據。 使用Google Analytics v4

4>專門針對GAV4(憑借我自己的經驗),可以看到錯誤“找不到廣告系列數據”。 嘗試以詳細模式運行代碼,您將看到GAV4正在與其主機建立連接。

GoogleAnalytics.getInstance(this).getLogger().setLogLevel(LogLevel.VERBOSE);

5>不要打開dry_run,您將無法在Google Analytics上看到數據。 默認情況下,這是關閉的。

6>最后,Google Analytics內部會在“實時”下查看實時點擊。

希望這可以幫助。

我有時會遇到ClassNotFound的額外錯誤。

首先我建議看看Nishant的回復,還有一件事要檢查他們是否解決了你的問題:

1)如果您有多個BroadcastReceiver:

1.1)確保你沒有! 只保留一個並將intent-filter添加到該那個:

  <service android:name="com.google.android.gms.analytics.CampaignTrackingService"/> <receiver android:name="com.example.MyScheduleReceiver" android:exported="true"> <intent-filter > <action android:name="android.intent.action.ACTION_USER_PRESENT" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE"/> <action android:name="android.intent.action.ACTION_SCREEN_OFF" /> <action android:name="android.intent.action.ACTION_SCREEN_ON" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> 

1.2)然后在BroadcastReceiver結束時將意圖發送給右邊的接收者:

@覆蓋
public void onReceive(Context context,Intent intent){

  //Do your code for the other intents new CampaignTrackingReceiver().onReceive(context, intent); 

}

2)在閱讀Google教程時,調用正確的Google Analytics版本也是一個問題,因為有些鏈接會將您重定向到舊版本的庫。 如果您使用的是v4,那么:

2.1)確保不包括libGoogleAnalyticsV2.jar

2.2)仔細檢查您是否一直在編寫com.google.android.gms.analytics .CampaignTrackingService以及所有導入。

3)使用ADB檢查其工作是否驗證了以前的要點。 在上面的例子中,調用ADB的右邊是:

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.example/com.example.MyScheduleReceiver --es  "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

為此,使用CustomReceiver並將其發送到GoogleAnalyticsv4中的google CampaignTrackingReceiver。

通過這個,您將在日志中獲得CampaignFound

public class CustomCampaignTrackingReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {

    new CampaignTrackingReceiver().onReceive(context, intent);
}
}

將apk文件安裝到您的設備。

adb install filename.apk

鍵入以下adb命令:

..\sdk\platform-tools>adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n your.package.name/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testSource"

請注意,此鏈接中給出的命令具有V3接收器。

檢查logcat。 Campaign Found消息應該在那里。 確保在發送引薦來源時應用程序未運行。 該應用程序應在完成后啟動。

可能對某人有用......我得到了GAv4: Discarding hit. Missing tracking id parameter GAv4: Discarding hit. Missing tracking id parameter因為而不是:

GoogleAnalytics.getInstance(context).newTracker(R.xml.app_tracker);

我已經添加

GoogleAnalytics.getInstance(context).newTracker(R.string.ga_trackingId);

注意差異xml.app_tracker vs string.ga_trackingId

使用xml.app_tracker配置文件!

當我查看我的上一個實現時。 也許日志可以被打破。 我在日志中收到“未找到廣告系列數據”,但我在網絡控制台中看到了真實數據。

我使用的是v4,我的清單看起來像這樣:

<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver" android:exported="true">
          <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
          </intent-filter>
        </receiver>
        <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />

祝好運

暫無
暫無

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

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