-
Notifications
You must be signed in to change notification settings - Fork 27
How to setup Google Analytics in Dashboard
📦 PHP cURL extension http://php.net/manual/fr/book.curl.php
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
:
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
)
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 :
- Enable the Google Analytics API service in
APIs & auth
=>APIs
: -
Create new Client ID
with OAuth and chooseService account
: - 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) Theclient_id
must be an email and look like this[email protected]
. You will found this email when you have Created your new 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 addga:
before the ID andView ID
: -
'private_key' => __DIR__ . '/analytics-certificate.p12'
Now you will download a certificate file with a.p12
extension and rename this file inanalytics-certificate.p12
and put this file intoconfig/analytics-certificate.p12
like this : The certificate can be download here :
- Set the authorization in your Google Analytics :
Admin
=>Property
=>Manage Users
Change toCollaborate and Read & Analyze
:
Congralutation, you have setup your first Google 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. 😄