问题
I have an app which is linked to (via an Android Market URL) on several different websites. What I need to implement is a way to determine where my users came from. Is there a way to determine the referring URL that the user followed to download my app via the Android Market?
For example, user A browses site xyz.com and clicks the link to view my app on the Android Market and then proceeds to download it. Once installed can I "programmaticaly" see where the user came from (xyz.com)?
I need to implement this myself (within the app) and not rely on external tools or services.
回答1:
It is possible to use Google Analytics to track the usage of your App.
On Android Google Analytics provides a refferal tracking. This should enable you to create a link for each of the sites that link to your app and track how much apps where installed because of which site.
Look at the Tracking Referrals chapter from the Android Google Analytics Documentation for more information.
You have to rely on the Google Analytics jar that has to be called within the app and registered in the manifest.xml
Update
If you don't want to use a separate jar you could try to obtain the referral information yourself. Google analyticss work through registering this Intent filter:
<!-- Used for install referrer tracking -->
<receiver android:name="com.google.android.apps.analytics.AnalyticsReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
It seems that the market app will send the specified intent just after installing an app from the market. The intent then will be catched from the AnalyticsReciever class and they will save the referrer for later use in the analytics.
Google states that this is how it works:
The Android 1.6 OS release supports the use of a referrer URL parameter in download links to the Android Market. The Google Analytics SDK for Android uses this parameter to automatically populate referral/campaign information in Google Analytics for your application. This enables the source of the application install to be recorded and associated with future pageviews and events.
This also means that the sites linking to you app have to include a specific parameter in the market url. How this is done is also explained in the Google Analytics Documentation.
回答2:
Afaik no.
However you could use URL shortening service that remembers HTTP referer, then you would share that URL with the websites. One such service is referer.us.
Or you could roll your own on AppEngine (reliable & free) with HttpRedirectFilter.
Edited:
Pls take a look at @Janusz post. He presented the right solution.
来源:https://stackoverflow.com/questions/4069864/determine-whether-a-user-installed-our-app-via-market-link