2017 © Pedro Peláez
 

symfony-bundle google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

image

happyr/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  • Monday, May 21, 2018
  • by Nyholm
  • Repository
  • 3 Watchers
  • 37 Stars
  • 97,926 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 15 Forks
  • 4 Open issues
  • 22 Versions
  • 7 % Grown

The README.md

Google Analytics Bundle

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads, (*1)

GoogleAnalyticsBundle is a Symfony2 bundle that helps you to push data to Google Analytics. It could be data like pageview, events etc. It is a bundle implementation of the Measurement Protocol, (*2)

This is not a library to pull data from Google analytics. That feature is deprecated from the classic-analytics branch. The master branch and version 3 and above will be supporting Google analytics universal., (*3)

Special feature

This bundle has a special feature. Say that you want to post data to Analytics. You want to post an event every time someone downloads a file. You may do that from the server like any other library. When looking at the reports you will find that you are missing the information about the actual user for the download event. You can not use a segment to find out which referal the user came from., (*4)

This bundle helps you with just that. Before we submit any data we look at the _ga cookie to find the user's clientId. So now you may use segments and advanced queries to analytics and you will get the expected result., (*5)

Usage

Read the documentation of the protocol., (*6)

``` php, (*7)

//in some container aware class $tracker = $this->get(Tracker::class); $data=array( 'dh'=>'mydemo.com', 'dp'=>'/home', 'dt'=>'homepage', ); $tracker->send($data, 'pageview');, (*8)


## Installation Install with composer. ``` bash composer require happyr/google-analytics-bundle

Step 2: Register the bundle

Register the bundle in the AppKernel.php, (*9)

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Happyr\GoogleAnalyticsBundle\HappyrGoogleAnalyticsBundle(),
    // ...
);

Step 3: Configure the bundle

``` yaml, (*10)

app/config/config.yml

happyr_google_analytics: // ... tracking_id: UA-XXXX-Y, (*11)


### Step 4: Provide a HTTP client and message factory service. You need to provide two services to that know how to create and send message factories. The services must implement `Http\Message\RequestFactory` and `Http\Client\HttpClient`. If you use [HTTPlugBundle](https://github.com/php-http/HttplugBundle) this will be taken care of automatically. You will aslo get some nice logging features. ``` yaml # app/config/config.yml happyr_google_analytics: // ... http_client: 'httplug.client' http_message_factory: 'httplug.message_factory

Fetching data

If you want to fetch data from Google Analytics you must install and configure GoogleSiteAuthenticatorBundle. Read its documentaion and then configure the analytics bundle with a client service and a view id. The view id is found in the admin section on Google analytics. Go to Admin > Account > Property > View > View settings., (*12)

``` yaml, (*13)

app/config/config.yml

happyr_google_analytics: // ... tracking_id: UA-XXXX-Y fetching: client_service: 'google.client.tobias_gmail' view_id: 0123456789 cache_service: 'cache.provider.my_memcached' # optinally a PSR6 cache service cache_lifetime: 3600 # default, (*14)


You may then run the following code to get the page views for /example-page. ``` php $fetcher = $this->get(AnalyticsDataFetcher::class); $pv = $fetcher->getPageViews('/example-page');

The Versions

06/03 2016

4.0.0-beta

4.0.0.0-beta http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

19/02 2015

3.2.2

3.2.2.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

21/12 2014

3.2.1

3.2.1.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

09/12 2014

3.2.0

3.2.0.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

23/11 2014

3.1.0

3.1.0.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

21/07 2014

3.0.1

3.0.1.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google.

  Sources   Download

MIT

The Requires

 

analytics google google analytics

19/07 2014

3.0.0

3.0.0.0 http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

analytics google google analytics

11/07 2014

dev-classic-analytics

dev-classic-analytics http://developer.happyr.com/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

23/01 2014

2.0.0

2.0.0.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

03/01 2014

1.2.2

1.2.2.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

09/11 2013

1.2.1

1.2.1.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

13/09 2013

1.2.0

1.2.0.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

29/07 2013

1.1.1

1.1.1.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

09/07 2013

1.1.0

1.1.0.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

07/07 2013

1.0.3

1.0.3.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

07/07 2013

1.0.2

1.0.2.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

07/07 2013

1.0.1

1.0.1.0 http://developer.happyr.se/symfony2-bundles/google-analytics-bundle

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

The Development Requires

analytics google google analytics

04/07 2013

1.0.0

1.0.0.0 http://developer.happyr.se

The Google Analytics Bundle lets you send data (like event tracking) to Google and receive data (like page statistics).

  Sources   Download

MIT

The Requires

 

analytics google google analytics