1. Home
  2. Control Panel
  3. Linking Google Analytics

Linking Google Analytics

Overview

Hosting platforms v5+ support easy integration of Google Analytics into your Dashboard. Analytics provide a bevvy of useful metrics including unique visitor count, visitor behavior, SEO efficacy, goal targeting, and browser usage.

Sample Dashboard with integrated Analytics

Sample Dashboard with integrated Analytics

Enabling Analytics

Analytics requires setup within Google Code and the control panel.

Prerequisite: Google Analytics must be setup before completing this. See KB: Enabling Google Analytics support.

Configuring within Google Code

  1. Login to Google Code API Console using your Google account.
  2. Go to APIs & Auth > Credentials to create a new OAuth Client ID.
  3. Click on Create new Client ID to generate a new API ID. This will be used in the control panel to access Analytics.
    • OPTIONAL: If you have not previously created a product, you’ll be prompted to create one on the consent screenPrompt to create product ID on Consent screen
    • Click to edit the consent screen, and enter a project name such as Apis Control Panel, then click Save to create this projectCreate a project name
  4. Select Application type > Web application
  5. Under Authorized JavaScript origins, enter the suggested origin under Account > Settings. If no API key has been submitted yet, this value will appear. If an API key is present, delete it to view the suggested origin.

    Settings” width=”300″ height=”99″ />

    Suggested authorized origin in Account > Settings

    • Use the secure variant, https://, unless you are connecting to the panel over http://
  6. Click Create ID
    • This is a sample input generated from a server, your Authorized JavaScript origins and Authorized redirect URIs will differ if on a different server.

      Configured Client ID dialog generated for an account on the server named “Sol”

  7. Copy the Client ID value generated. This will be used later under Configuring within the control panel.

    Sample client ID generated within Google's API console. Client ID masked for security.

    Sample client ID generated within Google’s API console. Client ID masked for security.

  8. Authorize control panel access to the Analytics API via APIs & AuthAPIs. Under API Library, search for “Analytics API“.
    • Select Analytics API.
  9. Click on Enable API if it is not enabled on your account.
    Enable API button to enable Analytics data sharing within the control panel.

    Enable API button to enable Analytics data sharing within the control panel.

Configuring within the control panel

  1. Visit Account > Settings. Under Control Panel enter the Client ID generated in the above section into Google Analytics API Key.
  2. Click Save Changes
  3. Visit Web > .htaccess Manager (note: this can also be done via the htaccess directive ModPagespeedAnalyticsID)
  4. Click the Edit action to edit the domain or subdomain to add integration.
  5. Click Add Directive to expand the directive dialog.
  6. Under Personality select Pagespeed
    1. Configure PageSpeed to use your Analytics ID:
      1. For Directive, select ModPagespeedAnalyticsID
      2. For Value enter your Analytics ID created in KB: Enabling Google Analytics support
      3. Click Add
        Sample input configuring your Analytics ID.

        Sample input configuring your Analytics ID.

    2. Configure PageSpeed to inject reporting JavaScript into your web pages:
      1. Enable inline Analytics injection now by changing Directive from ModPageSpeedAnalyticsID to ModPageSpeedEnableFilters
      2. Change Value from your Analytics ID previously entered to insert_ga
      3. Click Add
    3. Save Changes to save your new .htaccess file
  7. Go back to AccountDashboard. Click Access Google Analytics button to authenticate.
    Access Google Analytics button to sign-on and begin sharing data with the control panel.

    Access Google Analytics button to sign-on and begin sharing data with the control panel.

    • Important: if you receive an “Error: origin_mismatch” message, then you have incorrectly entered the Authorized JavaScript origins. Return to the previous section to correct. Origin changes may take up to 15 minutes to propagate.
  8. Refresh the page. Statistics will load.
    • If statistics fail to load, ensure Analytics API has been enabled (see previous section).

Disabling Analytics

Visit Account > Settings > Control Panel section > Google Analytics API Key > Delete to remove API key access. This will also disable integrated Analytics.

Limitations

Analytics only works on well-formed HTML pages. Raw files are never reflected in byte usage. For example, linking to a file directly, such as the 100 MB test file, is never reflected in usage (click as much as you’d like! it is not reflected in Google Analytics usage). However, loading an image, such as the logo or control panel sample image on lithiumpanel.com, inline as part of a web page is reflected. This discrepancy occurs because Analytics must include itself in valid HTML. Sending a raw file precludes bootstrapping by lack of a HTML document.

Updated on April 15, 2020

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help! If you get an error, visit https://lithiumhosting.com/support instead.
Contact Support