Reputation: 1097
I was trying to setup google Analytics for campaign measurement and was going through this link: https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#general-campaigns
The code in this link is something like this:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Set screen name.
t.setScreenName(screenName);
// In this example, campaign information is set using
// a url string with Google Analytics campaign parameters.
// Note: This is for illustrative purposes. In most cases campaign
// information would come from an incoming Intent.
String campaignData = "http://examplepetstore.com/index.html?" +
"utm_source=email&utm_medium=email_marketing&utm_campaign=summer" +
"&utm_content=email_variation_1";
// Campaign data sent with this hit.
t.send(new HitBuilders.ScreenViewBuilder()
.setCampaignParamsFromUrl(campaignData)
.build()
);
My question is how to get the campaignData from an incoming event?
Kindly help.
Upvotes: 0
Views: 900
Reputation: 792
There are two types of campaign tracking:
Install Campaigns tracks app installs and is done by including specific intent to your app manifest.
General Campaigns are tracking launches of your apps (app is already installed and user is clicking on a deep link, e.g. like: app://myapp/deeplink?utm_source=...)
In your example (generic campaigns), campaign data are supposed to come from this specific deep link.
In this example ("examplepetstore.com/index.html?utm_source=email&utm_medium=email_marketing&utm_campaign=summer&utm_content=email_variation_1") text in bold is your campaign data and your marketing team is creating it. GA library recognises these parameters in the setCampaignParamsFromUrl()
.
General Campaigns or Launch Campaigns allows you to track which source (utm_source, utm_campaign, utm_medium) was used to open an already installed app. This is done via deep linking mechanism and if you are familiar with deep linking - you are good to go.
See here for deep linking implementation for Android.
In your AndroidManifest.xml
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This presumes you have MainActivity class in your app.
Upvotes: 2