Aller au contenu

omnireach/ga4 Référence de l’API

Étage
Fournisseur · Omnireach
Version
1.x
Suite de conformité
non branchée
Vérifié en réel
Vérifié en partie
Licence
MIT
composer require omnireach/ga4:1.x-dev

Lue dans les fichiers PHP du paquet au commit f779e42c2500 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.

Omnireach\Ga4

  • Ga4Factory class

    Google Analytics 4, from its options:

    4 options · 1 method · 1 constant

  • Ga4Provider class

    The Google Analytics Data API (https://developers.google.com/analytics/devguides/reporting/data/v1): POST properties/{id}:runReport - date range, dimensions, metrics, EXACT string filters, pages of rows (limit, offset) - with a bearer token.

    5 methods

  • GoogleToken class

    A bearer token for a Google API: the one given, or one obtained for a service account - a JWT signed with its private key (RS256) exchanged at its token_uri (the OAuth 2.0 JWT bearer grant, RFC 7523) - and kept until a minute before it expires.

    4 methods

Omnireach\Ga4

Ga4Factory class

final class Ga4Factory extends ProviderFactory Ga4Factory.php:21

Google Analytics 4, from its options:

property the GA4 property's numeric id (Admin, Property details) - not the "G-" measurement id credentials a service account's JSON key, or the path of its file - the account given the Viewer role on the property (Admin, Property access management); or: access_token a token with the analytics.readonly scope, obtained elsewhere url https://analyticsdata.googleapis.com/v1beta

Options

OptionDefault
credentials''
access_token''
url'https://analyticsdata.googleapis.com/v1beta'
propertyrequired
const SCOPE = 'https://www.googleapis.com/auth/analytics.readonly'

Ga4Factory::__construct()

public function __construct(readonly ?HttpClientInterface $http = null)

Ga4Provider class

final class Ga4Provider implements AudienceInterface Ga4Provider.php:19

The Google Analytics Data API (https://developers.google.com/analytics/devguides/reporting/data/v1): POST properties/{id}:runReport - date range, dimensions, metrics, EXACT string filters, pages of rows (limit, offset) - with a bearer token.

Ga4Provider::__construct()

public function __construct(readonly JsonApi $api, readonly GoogleToken $token, readonly string $property, readonly string $url = 'https://analyticsdata.googleapis.com/v1beta')

Ga4Provider::getName()

public function getName(): string

Ga4Provider::getTitle()

public function getTitle(): string

Ga4Provider::capabilities()

public function capabilities(): Capabilities

Ga4Provider::audience()

public function audience(ReachQuery $query): Report

GoogleToken class

final class GoogleToken GoogleToken.php:18

A bearer token for a Google API: the one given, or one obtained for a service account - a JWT signed with its private key (RS256) exchanged at its token_uri (the OAuth 2.0 JWT bearer grant, RFC 7523) - and kept until a minute before it expires.

The same class lives in omnireach/search-console and omnireach/ga4: two providers, one grant, no shared package for forty lines.

GoogleToken::__construct()

public function __construct(readonly JsonApi $api, readonly string $scope, readonly ?array $serviceAccount = null, ?string $token = null, readonly ?\Closure $clock = null)
$serviceAccount

the service account's JSON key, decoded (client_email, private_key, token_uri)

$clock

the present as a UNIX time (a test's); time() when null

GoogleToken::credentials()

public static function credentials(string $jsonOrPath): array

A service account's key: its JSON, or the path of its file.

GoogleToken::get()

public function get(): string

GoogleToken::assertion()

public function assertion(int $now): string

The signed JWT the token is asked with.