2017 © Pedro Peláez
 

symfony-bundle google-bundle

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

image

znanylekarz/google-bundle

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  • Monday, October 27, 2014
  • by prgTW
  • Repository
  • 2 Watchers
  • 1 Stars
  • 4,423 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 102 Forks
  • 0 Open issues
  • 5 Versions
  • 11 % Grown

The README.md

CI, (*1)

GoogleBundle

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps., (*2)

Installation

Initialize Submodule

git submodule add git@github.com:antimattr/GoogleBundle.git src/AntiMattr/GoogleBundle

Application Kernel

Add GoogleBundle to the registerBundles() method of your application kernel:, (*3)

public function registerBundles()
{
    return array(
        new AntiMattr\GoogleBundle\GoogleBundle(),
    );
}

Configuration

Google Analytics

Application config.yml

Enable loading of the Google Analytics service by adding the following to the application's config.yml file:, (*4)

google:
    analytics:
        trackers:
            default:
                name:      MyJavaScriptCompatibleVariableNameWithNoSpaces
                accountId: UA-xxxx-x
                domain:    .mydomain.com
                trackPageLoadTime: true

View

Include the Google Analytics Async template in the head tag or just before the </body> of your layout (The template will lazy load _gaq)., (*5)

With twig:, (*6)

{% include "GoogleBundle:Analytics:async.html.twig" %}

Features

Logging a Default Page View
Requires no additional code
Sending a Custom Page View
$this->container()->get('google.analytics')->setCustomPageView('/profile/'.$username);
Adding to Page View Queue

Note: Page View Queue is always executed before a Custom Page View, (*7)

$this->container()->get('google.analytics')->enqueuePageView('/my-first-page-view-in-queue');
$this->container()->get('google.analytics')->enqueuePageView('/my-second-page-view-in-queue');
Ecommerce Tracking
$transaction = new \AntiMattr\GoogleBundle\Analytics\Transaction();
$transaction->setOrderNumber('xxxx');
$transaction->setAffiliation('Store 777');
$transaction->setTotal(100.00);
$transaction->setTax(10.00);
$transaction->setShipping(5.00);
$transaction->setCity("NYC");
$transaction->setState("NY");
$transaction->setCountry("USA");
$this->get('google.analytics')->setTransaction($transaction);

$item = new \AntiMattr\GoogleBundle\Analytics\Item();
$item->setOrderNumber('xxxx');
$item->setSku('zzzz');
$item->setName('Product X');
$item->setCategory('Category A');
$item->setPrice(50.00);
$item->setQuantity(1);
$this->get('google.analytics')->addItem($item);

$item = new \AntiMattr\GoogleBundle\Analytics\Item();
$item->setOrderNumber('bbbb');
$item->setSku('jjjj');
$item->setName('Product Y');
$item->setCategory('Category B');
$item->setPrice(25.00);
$item->setQuantity(2);
$this->get('google.analytics')->addItem($item);

Google Adwords

Application config.yml

Enable loading of the Google Adwords service by adding the following to the applications's config.yml file:, (*8)

google:
    adwords:
        conversions:
            account_create:
                id:    111111
                label: accountCreateLabel
                value: 0
            checkout_thanks:
                id:    222222
                label: checkoutThanksLabel
                value: 0

Controller

$this->get('google.adwords')->activateConversionByKey('account_create');

View

Include the Google Adwords tracking template like this, (*9)

{% include "GoogleBundle:Adwords:track.html.twig" %}

Google Maps - Static Map

Application config.yml

Enable loading of the Google Maps Static service by adding the following to the applications's config.yml file (The static service does NOT require an API Key):, (*10)

google:
    maps: ~

Controller

use AntiMattr\GoogleBundle\Maps\StaticMap;
use AntiMattr\GoogleBundle\Maps\Marker;

...

$map = new StaticMap();
$map->setId("Paul");
$map->setSize("512x512");
$marker = new Marker();
$marker->setLatitude(40.596631);
$marker->setLongitude(-73.972359);
$map->addMarker($marker);
$this->container->get('google.maps')->addMap($map);

View

Include the Google Maps in your template like this:, (*11)

{% if google_maps.hasMaps() %}
    {% for map in google_maps.getMaps() %}
        {% autoescape false %}
            {{ map.render }}
        {% endautoescape %}
    {% endfor %}
{% endif %}

The Versions

27/10 2014

dev-master

9999999-dev

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  Sources   Download

MIT

The Requires

 

analytics google maps adwords

17/07 2012

dev-fix/analytics-allow-optional-event-args

dev-fix/analytics-allow-optional-event-args

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  Sources   Download

MIT

The Requires

 

analytics google maps adwords

20/06 2012

dev-feature/analytics-allow-anchor

dev-feature/analytics-allow-anchor

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  Sources   Download

MIT

The Requires

 

analytics google maps adwords

11/06 2012

dev-feature/analytics-disable-name-prefix-on-tracker

dev-feature/analytics-disable-name-prefix-on-tracker

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  Sources   Download

MIT

The Requires

 

analytics google maps adwords

11/06 2012

dev-feature/tech-debt-analytics

dev-feature/tech-debt-analytics

The GoogleBundle adds the ability to add various google-related services to your application. These include Google Analytics, Adwords and Static Maps.

  Sources   Download

MIT

The Requires

 

analytics google maps adwords