Integrating with Google Analytics for mobile

Note: this document is for sending Tapstream data to your Google Analytics for Mobile dashboard.

For sending Tapstream data to your Google Analytics for Web dashboard, please see the Integrating with Google Analytics for Web documentation.

If you use the Google Analytics Android or iOS SDK in your app, you can add Tapstream's user attribution information as campaign parameters to your Google Analytics tracking.

Tapstream's SDK includes a feature called Onboarding Links. This feature allows your app to register for a callback that will return the attribution information for the user, if available.

This callback is documented in the platform-specific Tapstream SDK documentation - please refer to it.

Register for this callback and parse the JSON that it gives you.

From the parsed JSON, retrieve the value of tracker from the first hit object. This is the slug of the Tapstream campaign link that brought your user to the app.

Google Analytics provides a facility for reporting custom campaign information. Report the value of tracker using this.

iOS implementation

Here's how you can send Tapstream conversion information to Google Analytics via the GA iOS SDK. (Replace @"tapstream-campaign-link" with the value of tracker from your JSON.) Code example from Google Analytics' campaign measurement docs for iOS.

// Assumes at least one tracker has already been initialized.
id<GAITracker> tracker = [[GAI sharedInstance] defaultTracker];

NSMutableDictionary *campaignData = [NSDictionary alloc dictionaryWithObjectsAndKeys:
    @"tapstream-campaign-link", kGAICampaignName, nil];

// Note that the campaign data is set on the Dictionary, not the tracker.
[tracker send:[[[GAIDictionaryBuilder createAppView] setAll:campaignData] build]];

Android implementation

Here's how you can send Tapstream conversion information to Google Analytics via the GA Android SDK. (Replace "tapstream-campaign-link" with the value of tracker from your JSON.) Code example from Google Analytics' campaign measurement docs for Android.

// May return null if EasyTracker has not yet been initialized with a property ID.
EasyTracker easyTracker = EasyTracker.getInstance(this);
easyTracker.set(Fields.SCREEN_NAME, "Home Screen");

Map<String, String> campaignData = new HashMap<String, String>();
campaignData.put(Fields.CAMPAIGN_NAME, "tapstream-campaign-link");

MapBuilder paramMap = MapBuilder.createAppView();

// Campaign data sent with this hit.
// Note that the campaign data is set on the Map, not the tracker.
easyTracker.send(paramMap
    .setAll(campaignData).build()
);