helsingborg-stad/google-analythics

Plugin to integrate Google Analytics and display simple statistics.

Installs: 921

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 13

Forks: 0

Open Issues: 11

Type:wordpress-plugin


README

Plugin to integrate Google Analytics tracking and display statistics on the admin dashboard. It requires a Google Service Account with read permissions connected to the desired Google Analytics web property.

Getting started

Install libraries

This plugin requires Google APIs Client Library for PHP and is installed with Composer:

composer install

Google Service Account setup

  • Create a Project in the Google APIs Console
  • Enable the Analytics API under APIs & services
  • Create a Service Account for the project with view cababilities
  • Download the private key (JSON)
  • Finally add Service account ID as a new user to your Google Analytics account.

Filters

GoogleAnalytics/TrackingId/ua

Filters the Google Analytics UA (user id) used to load Google Analytics.

  • @param string $ua - The Google Analytics UA
apply_filters('GoogleAnalytics/TrackingId/ua', $ua);