Skip to content

How to setup Google Analytics in Dashboard

Xety edited this page Oct 7, 2014 · 7 revisions

Requirements

📦 PHP cURL extension http://php.net/manual/fr/book.curl.php

Create your Google Analytics Account

First you will need to setup your Google Analytics account. I asume you know how to do that and how to generate the code to insert in a HTML page. Now you have the code, you will change a configuration key in the file config/xeta.php : Analytics Tracker You just need to set your code tracker, the code to insert in a HTML page is already setup (In src/Template/Element/google-analytics.ctp)

Configure your Google Analytics API

Now we will setup the Google Analytics API, this setup will take a little time, please follow strictly the steps below :

  • Create a Google Project. The page look like this : pqgkzra
  • Enable the Google Analytics API service in APIs & auth => APIs : Enable the Google Analytics API service
  • Create new Client ID with OAuth and choose Service account : Create new Client ID
  • Now you will setup the file config/app.php :
'Analytics' => [
	'enabled' => false
	'start_date' => '',
	'client_id' => '',
	'profile_id' => '',
	'private_key' => ''
]
  • Keys configuration :
    • 'enabled' => true
    • 'start_date' => '2014-08-01' (For exemple)
    • 'client_id' => 150859763316-ml1ur664lsu2q4k4rpv7r1fc2bedi7pe@developer.gserviceaccount.com (For Exemple) The client_id must be an email and look like this [email protected]. You will found this email when you have Created your new Client ID : client_id
    • 'profile_id' => 'ga:58288350' (For exemple) You will found this ID, in your Google Analytics Account : Admin => View column => View Settings : Don't forget to add ga: before the ID View Settings and View ID : View ID
    • 'private_key' => __DIR__ . '/analytics-certificate.p12' Now you will download a certificate file with a .p12 extension and rename this file in analytics-certificate.p12 and put this file into config/analytics-certificate.p12 like this : analytics-certificate The certificate can be download here : download certificated
  • Set the authorization in your Google Analytics : Admin => Property => Manage Users screenshot_19 Change to Collaborate and Read & Analyze : screenshot_20

Congralutation, you have setup your first Google Analytics API ! 😅

Some errors that occurred when i installed my Analytics API

  • Curl error (60): SSL Certificate problem: Unable to get local issuer certificate

This error means that the cURL extension is not properly configured.

  • Go to http://curl.haxx.se/docs/caextract.html and download the file cacert.pem.
  • Put this file where you want, but idealy, i have placed this file into : C:\Program Files (x86)\Wamp\bin\php\php5.5.12\cacert.pem.
  • Open your php.ini and search curl.cainfo and uncomment the line by removing the # and setup like this : curl.cainfo = "C:\Program Files (x86)\Wamp\bin\php\php5.5.12\cacert.pem", save and restart your server.

If you had some error and you successfully resolved your error, please contact me and i will add your error in this list to help people. 😄