Reusing Google Analytics tagging

You can reuse your Google Analytics data to target your users with the Xtremepush Google Analytics Integration. To enable this you will need to do some work on the App-side and on the Platform.

App-side

iOS

To enable the Google Analytics targeting feature, call the following method with the Google Analytics ID as the second param where this is available:

// iOS enable google analytics targeting

XPush.hitTag("user.ga_id", withValue:GA_ID);
// iOS enable google analytics targeting

[XPush hitTag:@"user.ga_id" withValue: GA_ID];

The Google Analytics ID can be retrieved using the following method from the GA SDK.

tracker.get(kGAIClientId)
[tracker get:kGAIClientId]

This ID should also be set as a custom dimension on the GA tracker

// Set the custom dimension value on the tracker using its index.

tracker.set(GAIFields.customDimension(for: 1), value:GA_ID)
// Set the custom dimension value on the tracker using its index.


[tracker set:[GAIFields customDimensionForIndex:1]  value:GA_ID];

If you have a user id you send to Xtremepush, you can set that as a custom dimension as well if you don't do this already.

tracker.set(GAIFields.customDimension(for: 2), value:YOUR_User_ID)
[tracker set:[GAIFields customDimensionForIndex:2]  value:YOUR_User_ID];

Your user ID should also be set as the user ID on the GA tracker.

tracker?.set(kGAIUserId, value:YOUR_User_ID)
[tracker set:kGAIUserId value: YOUR_User_ID];

Finally, after completing the above settings, a ScreenView can be sent

tracker.send(GAIDictionaryBuilder.createScreenView().build() as! [AnyHashable : Any]!)
[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

👍

IDs should be sent with every hit

Android

To enable the Google Analytics targeting feature call the following method with the Google Analytics ID as the second param where this is available.

// Android enable google analytics targeting

mPushConnector.hitTag("user.ga_id", GA_ID);

The Google Analytics ID can be retrieved using the following method from the GA SDK.

tracker.get("&cid");

The GA_ID and the YOUR_User_ID should also be set as custom dimensions on the GA tracker. For example a ScreenView can be sent as follows:

// Send the custom dimension with a screen view.

       tracker.send(new HitBuilders.ScreenViewBuilder()

           .setCustomDimension(1, GA_ID )

           .setCustomDimension(2, YOUR_User_ID )

           .build()

       );

👍

IDs should be sent with every hit