Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fourlabsldn/gampbundle
Google Analytics Measurement Protocol bundle for Symfony
https://github.com/fourlabsldn/gampbundle
Last synced: 5 days ago
JSON representation
Google Analytics Measurement Protocol bundle for Symfony
- Host: GitHub
- URL: https://github.com/fourlabsldn/gampbundle
- Owner: fourlabsldn
- License: mit
- Created: 2015-08-25T13:02:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-02-16T17:42:49.000Z (over 2 years ago)
- Last Synced: 2024-09-22T04:18:14.831Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 31
- Watchers: 4
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GAMP Bundle
Google Analytics Measurement Protocol Package for Symfony. Supports all GA Measurement Protocol API methods.[![Build Status](https://travis-ci.org/fourlabsldn/GampBundle.svg?branch=master)](https://travis-ci.org/fourlabsldn/GampBundle)
[![StyleCI](https://styleci.io/repos/41363602/shield?branch=master)](https://styleci.io/repos/41363602)
[![Total Downloads](https://poser.pugx.org/fourlabs/gamp-bundle/downloads)](https://packagist.org/packages/fourlabs/gamp-bundle)
[![License](https://poser.pugx.org/fourlabs/gamp-bundle/license)](https://packagist.org/packages/fourlabs/gamp-bundle)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/65a665f5-d868-40e4-9cee-1981958f018a/mini.png)](https://insight.sensiolabs.com/projects/65a665f5-d868-40e4-9cee-1981958f018a)## Installation
### Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest version of this bundle:``` bash
$ composer require fourlabs/gamp-bundle
```This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.
### Compatibility with Guzzle 5 and 6
If you are using PHP 5.5 or above and Guzzle 6 then:
{
"require": {
"fourlabs/gamp-bundle": "^2.0"
}
}Or if you are using PHP 5.4 or above and Guzzle 5 then:
{
"require": {
"fourlabs/gamp-bundle": "^1.1"
}
}### Enable the Bundle
Then, enable the bundle by adding the following line in the *app/AppKernel.php* file of your project:
``` php
get('gamp.analytics')
->setTransactionId('7778922')
->setAffiliation('THE ICONIC')
->setRevenue(250.0)
->setTax(25.0)
->setShipping(15.0)
->setCouponCode('MY_COUPON')
->setProductActionToPurchase()
->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent()
;
```Refer to [the library's documentation][2] for other remaining methods and examples, they all work. This library 100% supports all GAMP features.
> **Note:** You don't have to use the protocol version, tracking id, anonymize ip and async request (non-blocking) methods as they're automatically set in based on your config file.
[2]: https://github.com/theiconic/php-ga-measurement-protocol#usage
### Configuration
Example of configuration in `app/config.yml`:
four_labs_gamp:
protocol_version: 1
tracking_id: UA-XXXXXXX-X
use_ssl: true
anonymize_ip: false
async_requests: true
sandbox: trueSet your Google Analytics Tracking / Web Property ID in `tracking_id` key **[REQUIRED]**
See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid
``` yaml
tracking_id: UA-XXXX-Y
```All other configuration options are optional, use as per your requirements.
The Protocol version. The current value is '1'. Default: 1
See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v
``` yaml
protocol_version: 1
```To send data over SSL, set `use_ssl` to true. Default: true
See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid
``` yaml
use_ssl: true
```To Anonymize IP, set `anonymize_ip` to true. Default: false
See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#aip
``` yaml
anonymize_ip: true
```To Make Async Requests, set `async_requests` to true. Default: true
``` yaml
async_requests: true
```When sandbox mode is enabled, no hits are actually sent to GA. In this case the library returns a AnalyticsResponseInterface object that with empty values. Default: false
``` yaml
sandbox: true
```## Credits
This package is a wrapper around the GA Measurement Protocol PHP Library. Thanks to the guys @ [THE ICONIC][1] who developed the library!
[1]: https://github.com/theiconic/php-ga-measurement-protocol
[2]: https://github.com/theiconic/php-ga-measurement-protocol#usage
[3]: http://symfony.com/doc/current/service_container/shared.html## License
[MIT](LICENSE)