Installation [8.x-3.0]

Last updated on
1 July 2024

Note: this guide was written for an outdated version of Google Analytics Counter which used Universal Analytics only.

Starting on July 1, 2023, standard Universal Analytics properties stopped processing new data, and there is no longer access to the Universal Analytics interface and API starting on July 1, 2024.

Guide for the latest version of the module for importing GA4 data.

Installation

1. Copy/upload the Google Analytics Counter module to the modules directory of your Drupal installation.

2. Enable the 'Google Analytics Counter' module in 'Extend'. (/admin/modules)

3. Set up user permissions. (/admin/people/permissions#module-google_analytics_counter)

4. Go to the settings page (/admin/config/system/google-analytics-counter). Review default settings and adjust accordingly.

  • For instance, the "Minimum time to wait before fetching Google Analytics data (in minutes)" field can usually be set to 0 except on the largest systems.
  • This setting, which may be deprecated in the future, is a setting which throttles the queries to Google. Since Google's quotas continue to increase as time goes on, this setting may just get in your way as you work to get the settings right for your system.
  • Likewise, on larger systems, it is probably preferable to increase the "Queue Time (in seconds)" so that all the queue items are processed in a single cron run.

5. Click Save configuration.

6. Create a project in Google Analytics. For more information, see instruction in the README.md included with the module or Create a Project in Google Analytics page in this documentation.

7. Once your project in Google Analytics is ready, and you have your Google Project Client ID, Client Secret, Authorized Redirect URI and, optionally, Google Project Name, go to the authentication page. (/admin/config/system/google-analytics-counter/authentication)

8. Add your Google Project Client ID, Client Secret, Authorized Redirect URI and, optionally, your Google Project Name to their likewise named fields on the authentication page.
See Create a Project in Google Analytics page in this documentation for how to set up a Google Analytics project.

9. Usually the 'Authorized Redirect URI' field will be the authentication page in Drupal.

10. The optional Google Project name field helps to take you directly to your Analytics API page to view Google's quotas. The Google Project name field should use the machine name of your Google project, like my-project. [Todo: add validation]

11. Click Save configuration.

12. Click the large button at the top of the page labeled 'Authenticate'.

13. In the pop up that appears from Google, select the google account to which you would like to authenticate.

14. Fill in credentials if requested by Google.

15. Click Allow.

16. If all goes well, you will be returned to the authentication page in Drupal because that is the page you added to the 'Authorized Redirect URI field when setting up configuration in both Drupal and Google Analytics.

17. Select a view from the select list under Google View.

  • A good way to tell that authentication with Google has succeeded is if you see your google analytics profiles listed in the Google View. If you did not successfully authenticate with Google the only option in Google View is 'Unauthenticated'.

18. Click Save configuration.

19. Check the Dashboard (/admin/config/system/google-analytics-counter/dashboard)

20. Note: most of the numbers on the dashboard are 0 until you run cron.

21. Run cron. Generally speaking, it is a good idea to run cron continuously with a scheduler like Jenkins or a crontab to keep pageviews data in Drupal up to date with Google.

22. Add the custom Google Analytics Counter field to one or more content type. See The custom Google Analytics Counter field for more information.

23. Place a Google Analytics Counter block on your site. (/admin/structure/block)

24. Enable the text filter (More to come).

Help improve this page

Page status: No known problems

You can: