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];

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

[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 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 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];

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

[tracker send:[[GAIDictionaryBuilder createScreenView] build]];

N.B. 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()

       );

N.B. IDs should be sent with every hit

 

On the Platform

To enable the integration via the platform first go to your google developer console and pick the project you will use to work with your website and google analytics:

https://console.developers.google.com/project

Developer Console

On your dashboard select Enable and Manage APIs:

Under Other popular APIs select Analytics API:

After selecting Analytics API click Enable API:

On the left hand navigation click Credentials, on the credentials page click New credentials:

 

 

After clicking New Credentials select Service account key then pick your service account, pick key type P12 and click create:

 

Your new key will be downloaded automatically (Make sure you are using Chrome as your browser) you will use this later:

 

After returning to the credentials page click Manage service accounts:

 

 

Copy the email associated with your service account:

 

Now that you’ve created your new service account you will need to add this ‘user’ to your Google Analytics account.

 

Google Analytics

Login to analytics and then go to the admin dashboard section.

 

Under the first column labeled ‘Account’ select ‘User Management’. Now go ahead and add the email address that is associated with your service account. It should be in the format xxxxxxxxxxxxx@xxxxxxxxx.gserviceaccount.com.

As we will only be using this account to extract data from your Analytics account you can set the user privileges to ‘Read & Analyze’.

Now go back to your Analytics admin dashboard and navigate to the ‘View Settings’ link, located in the third column ‘View’. Take a note of the ‘View ID’, this will be required later.

 

Now you must go to the your app settings on xtremepush to upload the service account email, cert and your google analytics view ID.

 

xtremepush

In your App home on xtremepush go to App Settings > Certs & Keys. Select the GOOGLE ANALYTICS radio button and upload the service account email, cert and your google analytics view ID generated as described above. Select the next available Google Analytics custom dimension (Dimension go from 1-20 for regular GA accounts). Save your settings and your Google Analytics integration is almost complete.

 

Just make sure to ad a corresponding custom dimension on Google Analytics. You can call this anything for example "xtrempush ID" just make sure the dimension number on the certs & keys page matches and the scope is User: 

Alternatively xtremepush can auto generate the custom dimension if you are happy to give the service account user you are using for the integration edit permissions in the user access management section of google analytics.

Then you can leave the custom dimension field blank and it will be auto generated when you save:

 

 

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.