Google Analytics

The Google Analytics module for DrupalGap.

Drupal Core: 

  • 7.x
  • 8.x

The Google Analytics module for DrupalGap.


1. Get a Tracking ID


2. Add configuration

Add this to your settings.js file:

dg.settings.google_analytics = {
  id: 'UA-XXXX-Y'

Replace the UA-XXXX-Y with your tracking id from step 1.

3. Add the tracking code

Add this snippet to your app's index.html file before the closing </body> tag:

<!-- Google Analytics -->
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', dg.config('google_analytics').id, 'auto');
ga('send', 'pageview');
<!-- End Google Analytics -->

If you are compiling your app, be sure to replace the // with instead.

4. Enable the module

Include the module in your index.html file:

<script src="modules/contrib/google_analytics/google_analytics.js"></script>