While the app includes support for Analytics for mobile apps, the amount of information collected will be much less than what your site’s own Analytics can collect, since almost every user action inside the app will correspond to a page load on your site.
To be able to isolate the app’s usage from the rest of web usage, you can use a Google Analytics feature called Custom Dimensions.
Adding a Custom Dimension to track your app’s usage
By adding a custom dimension in Google Analytics you’ll be able to track your app’s usage separately from the rest.
- Switch to the property where the data will be saved
- Click Admin, then select Custom Definitions, then Custom Dimensions
- Create a new custom dimension
- Choose “Canvas Mobile App” as the name
- Select “Session” in the Scope drop down menu
- Mark the “Active” checkbox
Take a note of the Dimension number used when it’s created.
To populate this with the right data, we need to add some code to your Analytics tag, so that the user agent is detected and tracked.
Custom dimensions and metrics are sent to Analytics as parameters attached to other hits, like pageviews. As such, custom dimension or metric values need to be set before a tracking call is made in order for that value to be sent to Analytics.
Find this line in your Analytics tracking code:
ga('create', 'UA-XXXX-Y', 'auto');
Now add this just below it.
var ua = navigator.userAgent || navigator.vendor || window.opera; ga('set', 'dimension1',(ua.indexOf("Canvas") > -1) ? 'Canvas' : 'None');
Note that if this isn’t the first Dimension you have created then you may need to change dimension1 to match the dimension number created in analytics earlier.
Now you can start using this new dimension in any reports within Analytics and filter users accessing your site through your Canvas mobile app.
For more information see these posts: