Campaign Measurement

Measuring campaigns in Google Analytics enables the attribution of campaigns and traffic sources to user activity within your application. The following sections will describe when and how to implement each type of campaign measurement in your app.

The automatic campaign tracking is available on Android. In order to track campaign you need to enable it into the plugin settings:

 

Alternatively, if you are using another platform or you have already had campaign information, you can specify it manually using the following code.

Google Example:

v=1             // Version.
&tid=UA-XXXX-Y  // Tracking ID / Property ID.
&cid=555        // Anonymous Client ID.

&t=event     // Pageview hit type.
&cn=http://example.com  // Document Referrer
&cn=(direct)      // Campaign Name
&cs=(direct)    // Campaign Source
&cm=organic   // Campaign Medium
&ck=Blue Shoes   // Campaign Keyword
&cc=content   // Campaign Content
&ci=ID   // Campaign ID
&gclid=CL6Q-OXyqKUCFcgK2goddQuoHg   // Google AdWords ID
&dclid=d_click_id   // Google Display Ads ID

 

Plugin Example:

using SA.Analytics.Google;

Manager.Client.CreateHit(GoogleAnalyticsHitType.EVENT);
Manager.Client.SetDocumentReferrer("http://example.com");
Manager.Client.SetCampaignName("(direct)");
Manager.Client.SetCampaignSource("(direct)");
Manager.Client.SetCampaignMedium("organic");
Manager.Client.AddCampaignKeyword("Blue Shoes");
Manager.Client.SetCampaignContent("content");
Manager.Client.SetCampaignID("ID");
Manager.Client.SetGoogleAdWordsID("CL6Q-OXyqKUCFcgK2goddQuoHg");
Manager.Client.SetGoogleDisplayAdsID("d_click_id");

Manager.Client.Send();

Android Manifest Requirements

Add the following tags right into your <application> tag of the main AndroidManifest.xml file

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