How To Get Referrer Using Google Track In Android?
Solution 1:
Not sure that Google lets you send arbitrary information. Try using the generator to create the url.
https://developers.google.com/analytics/devguides/collection/android/devguide#google-play-builder
Solution 2:
I have had a similar issue. Found it to be lifecycle problem: the onReceive of the install_referrer receivers are invoked AFTER my app's onResume(), on the SAME main thread, so any attempt to read the referrer file during onResume() fails. Here is the logcat to prove it, this was 100% reproducible over and over on 2 devices using Android 4.2.1 and 4.4.2:
First, play store broadcasts the referrer to the package on a separate (store) process:
11-04 14:17:51.558:D/Finsky(1737): [1] ReferrerRebroadcaster.doBroadcastInstallReferrer:Deliveredreferrerforcom.xxx.demo
The app onResume() - still no activation of the broadcast receivers! S
11-0414:17:51.888: D/XXX Main Activity(22730): onResume
The app tries to read the referrer (which the receivers should have stored using getSharedPreferences.putString):
11-04 14:17:51.958:I/XXX(22730):Extracted install referrer:
Only now the receivers are invoked on the main thread and will shortly try to write the referrer to a file:
11-04 14:17:51.918:I/XXX(22730):Received install referrer:abcdefg
As you can see, onResume() has no chance to actually read the file, so the extraction yields nothing. However, if I close the app and reopen it, onResume is now able to find the file and the referrer string gets processed - but not on first launch :)
Hope this helps!
Solution 3:
Google Analytics uses arbitrary constants in their SDK. for campaing_source is &cs.
Post a Comment for "How To Get Referrer Using Google Track In Android?"