Black Week 40% Off Promotion!!!
Download

Google Analytics Integration Plugin

This plugin allows you to integrate Google Analytics into your Publii site, providing access to a wealth of information on site traffic, user-behavior and other metrics that can be invaluable when seeking to improve the effectiveness of your site design, advertising and marketing. Usually, adding analytics to your site requires modification of your site files to add specific code snippets; this plugin takes care of that for you automatically; configure a few options in the plugin and you'll be ready to go in no time.

Creating a Google Analytics Account

To configure and enable this plugin you will need details from your Google Analytics account, so make sure to create one first. To do so, head to the Google Analytics Sign-Up Page and click on the Start for free button.

A detailed breakdown on how to set-up a Google Analytics account can be found in Google's Documentation. To enable the plugin in Publii, you will need to make a note of your website's Tracking ID provided by Google, as this is required for the plugin to function properly.

Enabling the Plugin

To activate the plugin, open the Tools & Plugins section of the Publii app via the left-menu to see a list of installed plugins. Click on the switcher button in the bottom-left of the Google Analytics Integration box in this list to enable the plugin.

You'll need to add some information to the plugin before it can function properly, so now click on the plugin box to open the Plugin Options screen.

Google Analytics Integration Options

Google Analytics provides a comprehensive and in-depth solution to data collection, so there are multiple options in the plugin that you can take advantage of your customize how the plugin functions. Note that the only required field in the options is the Tracking ID (you will also need to choose whether you are using a the GTM or gtag.js code variant). The other options may be changed as needed:

Configuration

  • Code Variant - This option sets whether the analytics code injected into your site uses the GTM (Global Tag Manager) or gtag.js (Global Site Tag) variant. The GTM variant offers a more complex and robust set of options that can be configured via your Google Analytics account, whereas the gtag.js variant has more limited options that are configurable via this plugin.
  • Tracking ID - The Tracking ID is the ID Google assigns to your analytics account to enable tracking of your site's usage data. To find it, log-in to your Google Analytics account, then click on the Admin > Tracking Info > Tracking Code options; the tracking code will start with G- followed by a string of numbers e.g. G-1A1A1A1A1A1.
  • Enable IP Anonymization - This option is only available when using the gtag.js code variant; for GTM, the option is controlled via your analytics account. When enabled, it allows for the data sent to Google Analytics from your site to be anonymous, providing greater protection for your users personally-identifiable information. More information on IP Anonymization can be found on the Google Analytics website.
  • Custom Code to Add to the Script - This option is only available when using the gtag.js code variant. If you need to include additional code to the base Google Analytics code snippet to, for example, include additional tracking options or functionalities, you may add it into this field.
  • Output Code in Preview Mode - If enabled, the Google Analytics code will be included when generating a preview of your site; this is useful for debugging, but should usually be turned off as it may skew the data collected by Google regarding your site traffic.

Cookie Banner Integration

  • Cookie Banner Integration -Enabling this option will add an option to the built-in Publii cookie banner for users to consent to cookies from Google. Google Analytics uses cookies to function correctly, and due to GDPR requirements, consent must be sought before any cookies that collect personally-identifiable information may be provided to the user's browser.
  • Cookie Group ID - This option only becomes available when the Cookie Banner Integration option is enabled. Here, you can specify the cookie group that the Google Analytics cookies should be added to, e.g. 'analitics'.  Make sure to add (if it doesn't exist) this group name to the GDPR section of the site settings. You can find instructions on how to do this in the GDPR section of this documentation.

What are you waiting for?

Start building your site today.

  1. 1 Download Publii
  2. 2 Write your content
  3. 3 Publish your site
Create website