Download the PHP package internetrix/silverstripe-ga-measurement-protocol without Composer

On this page you can find all versions of the php package internetrix/silverstripe-ga-measurement-protocol. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-ga-measurement-protocol

Google Analytics Measurement Protocol v1 for SilverStripe

Introduction

This module adds functionality to be able to send hits to Google Analytics via server side using Google's Measurement Protocol Version 1: https://developers.google.com/analytics/devguides/collection/protocol/v1

The module currently allows the sending of the following hits:

This is accomplished by constructing a GET request and using Guzzle to send the request to the Google Analytics endpoint.

Requirements

Installation

Install the module via composer:

Configuration & Setup

  1. Set the following variables for Internetrix\GaMeasurementProtocol\Model\GAHit in config:
    • useProductionGAProperty: Set this true if you want to use the Production tracking ID. Set to false if you want to send hits to staging.
    • stagingTrackingID: Google Analytics UA tracking ID for staging/testing property. Expected format: 'UA-XXXXXXXX-X'
    • productionTrackingID: Google Analytics UA tracking ID for production property. Expected format: 'UA-XXXXXXXX-X'

Example YML configuration:

Optional: Another useful config variable that is useful for debugging / testing is to set to true in config:

By setting useTestingEndpoint to true, when sending hits, the module will send the request to Google's Validation Server.

As Google's GA Measurement Protocol does not return HTTP error codes, by sending requests to the Measurement Protocol Validation Server, you can test the response. If the current SS environment is set to dev, it will also output the response to the browser / terminal.

More information on Google's Measurement Protocol Validation Server can be found here: https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits

Sending hits to a Production Google Analytics property

For hits to be sent to a Production property, all the following conditions must be met. Otherwise hits will ALWAYS be sent to staging property / debug endpoint.

Generate ClientID

IMPORTANT: When sending a GA hit, always ensure that the hit type is set and that a unique client ID is given. This module contains a function called setClientID to help developers add a client ID. The first parameter of function tells the function if the _ga cookie should be retrieved or not when creating a clientID. The second parameters allows a developer to override the clientID for a hit.

There are some ways this function can be used:

Usage Examples

The PHPDocs in GAHit.php contains links explaining what parameters are required for each type of event. Otherwise, please refer to the Official Google Analytics Measurement Protocol documentation

Example 1: Sending a Pageview hit to GA

Required Parameters:

Example 2: Sending an Event hit to GA

Required Parameters:

Example 3: Sending a Timing hit to GA

Required Parameters:

Adding Custom Dimensions, Custom Metrics and / or adding extra parameters to a hit

To add additional parameters like Custom Dimensions, Custom Metrics etc to a hit, use the addParameters method where $parameters should be an array with parameter name as the key, and the parameter value as the array value:

Todo

Licence

Please see License File for more information.


All versions of silverstripe-ga-measurement-protocol with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
silverstripe/framework Version ^4.0.0
silverstripe/cms Version ^4.0.0
guzzlehttp/guzzle Version ^6.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package internetrix/silverstripe-ga-measurement-protocol contains the following files

Loading the files please wait ....