Bablic provides statistics about language usage in your website, but sometimes we want to dive deeper into the analytics and integrate with our existing analytics framework.
Google Analytics JS SDK
We can add a dimension names bablic-language, which we can query on Google Analytics later on.
Add Custom Dimension in Google Analytics
Log-in to your Google Analytics account.
Click Admin, and navigate to the property to which you want to add custom dimensions
In the PROPERTY column, click Custom Definitions > Custom Dimensions.
Click New Custom Dimension.
Add a Name. "bablic-language".
Select the Scope Session.
Check the Active box.
Click Create.
The Custom Dimension table should look like this. Not that the dimension index is 1. If you have more dimensions, the index might be different, remember that index for later.
Send Analytics the user language code from Bablic
Your GA integration code might look like this:
ga('create', 'UA-SOME-ID', 'auto');
ga('send', 'pageview');
Edit it to create a new dimension:
ga('create', 'UA-SOME-ID', 'auto');
if(window.bablic && bablic.getLocale) {
ga('set', 'dimension1', bablic.getLocale());
}
ga('send', 'pageview');
If you custom dimensions before add Bablic dimension, the value "dimension1" should be replaced with the index in the custom-dimensions table in your Google Analytics account. (For example: "dimension4")
Generate Custom Analytics Report
Follow this guide to generate a custom report with your new custom dimension "bablic-language"