Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Outline

Google Analytics Data API Samples

Open in Cloud Shell

Description

These samples show how to use the Google Analytics Data API from PHP.

Build and Run

  1. Enable APIs - Enable the Analytics Data API and create a new project or select an existing project.
  2. Download The Credentials - Configure your project using Application Default Credentials. Click "Go to credentials" after enabling the APIs. Click "Create Credentials" and select "Service Account Credentials" and download the credentials file. Then set the path to this file to the environment variable GOOGLE_APPLICATION_CREDENTIALS:
    $ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
  1. Clone the repo and cd into this directory
    $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples
    $ cd php-docs-samples/analyticsdata
  1. Install dependencies via Composer. Run php composer.phar install (if composer is installed locally) or composer install (if composer is installed globally).
  2. Replace $property_id variable if present in the snippet with the value of the Google Analytics 4 property id you want to access.
  3. Run with the command php SNIPPET_NAME.php. For example:
    $ php quickstart.php

Contributing changes

Licensing

Morty Proxy This is a proxified and sanitized view of the page, visit original site.