Skip to main content

Google Analytics Setup

Getting credentials JSON

  1. Head over to Google APIโ€™s site using your google account and select or create a project. Imgur

  2. Set API's the project. Go to the API Library and search for "Google Analytics Data API". Imgur Imgur

  3. Choose enable to enable the API. Imgur

  4. If you dont have an Analytics account before, fill in the form like image below.

    • Go to Analytics site. Fill account name Imgur
    • Fill in property name, reporting time zone and currency. Imgur
    • Check anything that your business is about. Imgur
    • Check anything that your business objective. Imgur
    • Choose data collection to get Analytics Tracking ID Imgur
  5. Go to Google API and select a project that you want from the header.

  6. Go to Credential and create a new credential. Click Create Credentials and select Service account.

Imgur

  1. Fill in the form with service account name and account ID that you like. After that, click Create button and click Done.

Imgur

  1. To obtain service account credential JSON, press edit on the new created service account. Imgur

  2. Select KEYS menu from the tab. Click Add Key and select Create new key. After that, select JSON and click Create button. Imgur

  3. After you create the key, it'll automatically download the key.

  4. Place your .json key to storage directory like below.

๐Ÿ“ฆ Your Project
โ”ฃ ๐Ÿ“‚ storage
โ”ƒ โ”ฃ ๐Ÿ“‚ app
โ”ƒ โ”ƒ โ”ฃ ๐Ÿ“‚ analytics // If the directory doesn't exists, just create it
โ”ƒ โ”ƒ โ”ƒ โ”— ๐Ÿ“œ service-account-credentials.json // Filename must be the same

Granting permissions to your Analytics property

  1. Go to Google Analytics page.
  2. Select Admin menu from sidebar. Select Property access management ImgurImgur
  3. New window will appear, after that click Add users. Imgur
  4. Open the credential that we get before, search for client_email. Copy the email. Imgur
  5. Paste it in the Email addresses field and select permission that you want. You must check Viewer permissions. After that, press Done button. Imgur

Getting the ID that you need.

Account ID

  1. Select Admin menu from sidebar and select Account Details. Imgur

  2. There you have it. Imgur

Property ID / View ID

  1. Select Admin menu from sidebar and select Property Details. There you have it Imgur

Tracking ID

  1. Go to Analytics Home menu. There you have it Imgur

Web Property ID

  1. Open Google Analytics page.

  2. Look at the page URL. The web property ID start with p. Usually it has 9 character. For example: https://analytics.google.com/analytics/web/#/p299999997/reports/intelligenthome

    The web property ID for that account is 299999997.

Imgur