Skip to main content

Analytics

How to use Google Analytics as analytical solution

Since Google Analytics relies on cookie as storage by default. Using Google Analytics with default setting will hit cross-site cookie limitation on latest mobile browsers, as Link Game Platform will sandbox game content in a sandbox domain for enhanced privacy and security control.

Here describes a recommended way of using Google Analytics in Link Game Platform.

Installing analytics.js

In your index.html, append this snippet right after the SDK <script> element.

<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
</script>
<!-- End Google Analytics -->

Creating Tracker When SDK is Initialized

LinkGame.initializeAsync()
.then(()=>{
ga('create','UA-XXXXXXXX-YY',{ // Replace UA-XXXXXXXX-YY with your tracking ID
'storage':'none', // Disable using cookie for GA storage
'clientId':LinkGame.player.getID(), // Use player ID as identifier
});
});

Recording Page View

ga('send','pageview'); // Record a page view with current URL

For more advanced tracking use case, please refer to analytics.js documentations.

Note on Google Tag Manager

Unfortunately Google Tag Manager is not providing an obvious way to configure the storage option for Google Analytics tag. So if you have to use Google Tag Manager, you need to create Custom HTML tag with the snippet provided above instead of the Google Analytics tags.

Reference

https://developers.google.com/analytics/devguides/collection/analyticsjs

https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id#disabling_cookies

https://developers.google.com/analytics/devguides/collection/analyticsjs/pages