Android - Using Google Analytics v4 Campaign Measurement

喜你入骨 提交于 2019-11-28 21:59:07

First, did your package name is "com.example.gatestapp" ? because that what you wrote in the adb command. Second, did you put your "app.service.CustomReceiver" before the "CampaignTrackingReceiver" in the manifest? maybe the intent is intercept by CampaignTrackingReceiver and not by your receiver.

I secceeded to get the refferels in custom broadcast by:

Bundle extras = intent.getExtras();
String referrerString = extras.getString("referrer");

i find you question very useful for replicating that feature.

The issue looks like to be on the name of the package, I followed exactly the same procedure.

android_manifest.xml

<receiver
        android:name="co.tpaga.poc.referer.poc_installreferer.CustomInstallRefererReceiver"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

The adb command is:

echo 'am broadcast \
-a com.android.vending.INSTALL_REFERRER \
-n "co.tpaga.poc.referer.poc_installreferer/co.tpaga.poc.referer.poc_installreferer.CustomInstallRefererReceiver" \
--es "referrer" \
  "utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name&tappsi_uuid=04442-123123-213213-2323"; \                                     
exit' | ./adb shell

And the logcat exit is:

03-22 21:58:04.469 22340-22340/co.tpaga.poc.referer.poc_installreferer D/YEES: IT WORKS!!!utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name
03-22 21:58:04.469 22340-22340/co.tpaga.poc.referer.poc_installreferer D/YES: IT WORKS!!
03-22 21:58:04.477 22340-22394/co.tpaga.poc.referer.poc_installreferer D/GAv4: Received installation campaign: content=test_content, keyword=test_term, medium=test_medium, name=test_name, source=test_source
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!