PHPackages                             lexik/data-layer-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lexik/data-layer-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

lexik/data-layer-bundle
=======================

Manipulate the Google Tag Manager Data Layer from your Symfony application.

v1.1.1(8y ago)14114.2k↓50%6[1 PRs](https://github.com/lexik/LexikDataLayerBundle/pulls)MITPHP

Since Feb 17Pushed 7y ago5 watchersCompare

[ Source](https://github.com/lexik/LexikDataLayerBundle)[ Packagist](https://packagist.org/packages/lexik/data-layer-bundle)[ Docs](https://github.com/lexik/LexikDataLayerBundle)[ RSS](/packages/lexik-data-layer-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

LexikDataLayerBundle
====================

[](#lexikdatalayerbundle)

[![Latest Stable Version](https://camo.githubusercontent.com/66b5ded3a06540c97b772b8bedcee54b3c8e70e1c2d83a2fc807d1ae37053e2f/68747470733a2f2f706f7365722e707567782e6f72672f6c6578696b2f646174612d6c617965722d62756e646c652f762f737461626c65)](https://packagist.org/packages/lexik/data-layer-bundle)[![Build Status](https://camo.githubusercontent.com/c8083c4877316a987ed6d5899c21d5cc5b11d14803831fca32a90e74beab8368/68747470733a2f2f7472617669732d63692e6f72672f6c6578696b2f4c6578696b446174614c6179657242756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lexik/LexikDataLayerBundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/470110c920bba6b7bc4c922f2cdb636b703696e609b44617658a1121dcfcbae9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c6578696b2f4c6578696b446174614c6179657242756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lexik/LexikDataLayerBundle/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/fc7bbf7c67aa80aaf469e271327b01bb9eff0898f15c664e367eefa566aded72/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34643931643861352d336137662d343233622d396336662d3563313631323436613839312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/4d91d8a5-3a7f-423b-9c6f-5c161246a891)

Manipulate the Google Tag Manager Data Layer from your Symfony application. This bundle is compatible Symfony 2.7+, 3.0+ and 4.0+ and PHP 5.4+ to 7.0+.

Installation
------------

[](#installation)

Add [`lexik/data-layer-bundle`](https://packagist.org/packages/lexik/data-layer-bundle)to your `composer.json` file:

```
composer require "lexik/data-layer-bundle"

```

Register the bundle in `app/AppKernel.php`:

```
public function registerBundles()
{
    return array(
        // ...
        new Lexik\Bundle\DataLayerBundle\LexikDataLayerBundle(),
    );
}
```

Adding informations to the Data Layer
-------------------------------------

[](#adding-informations-to-the-data-layer)

To pass informations to the Data Layer use the `lexik_data_layer.manager.data_layer_manager` service directly.

#### Event / Session Data

[](#event--session-data)

##### Use case

[](#use-case)

Notify an application event that could be used as goal or conversion like a user registration.

##### Usage

[](#usage)

Get the service `lexik_data_layer.manager.data_layer_manager` and pass an associative array to it's `add()` method, it will be stored in session until it is passed to a page. Much like a Flash Message.

Using sessions as storage allows you to notify of an event even after a redirect for example.

Example usage from an EventListener to notify a user registration :

```
