Giter Club home page Giter Club logo

gampbundle's Introduction

GAMP Bundle

Google Analytics Measurement Protocol Package for Symfony2. Supports all GA Measurement Protocol API methods.

Total Downloads License SensioLabsInsight

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:

$ composer require fourlabs/gamp-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter 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
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FourLabs\GampBundle\FourLabsGampBundle(),
    );
}

Usage

Example
$this->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 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.

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

Set your Google Analytics Tracking / Web Property ID in tracking_id key [REQUIRED]

See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#tid

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

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

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

anonymize_ip: true

To Make Async Requests, set async_requests to true. Default: true

async_requests: true

To Do

  • Unit tests

Credits

This package is a wrapper around the GA Measurement Protocol PHP Library. Thanks to the guys @ THE ICONIC who developed the library!

License

MIT

gampbundle's People

Contributors

foaly-nr1 avatar nightbr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.