Download the PHP package lexik/data-layer-bundle without Composer
On this page you can find all versions of the php package lexik/data-layer-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lexik/data-layer-bundle
More information about lexik/data-layer-bundle
Files in lexik/data-layer-bundle
Package data-layer-bundle
Short Description Manipulate the Google Tag Manager Data Layer from your Symfony application.
License MIT
Homepage https://github.com/lexik/LexikDataLayerBundle
Informations about the package data-layer-bundle
LexikDataLayerBundle
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
Add lexik/data-layer-bundle
to your composer.json
file:
composer require "lexik/data-layer-bundle"
Register the bundle in app/AppKernel.php
:
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
Use case
Notify an application event that could be used as goal or conversion like a user registration.
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 :
Default Data
Use case
Set the user id on every page for example.
Usage example
Create a service implementing the Lexik\Bundle\DataLayerBundle\Collector\CollectorInterface
and tag it using the lexik_data_layer.collector
tag.
It's handle
method will be passed the current Data Layer array, which you can modify by adding or modifying its values.
Adding / Writing Data Layer variables to the page
Use the provided lexik_data_layer()
twig function to write the Data Layer value to a page template.
This will automatically reset the Data Layer informations stored in session.
Don't forget to use it BEFORE you insert the Tag Manager tag.
Testing
Setup the test suite using Composer:
$ composer install
Run it using PHPUnit:
$ vendor/bin/phpunit
Contributing
See CONTRIBUTING file.
Credits
- Nicolas Cabot [email protected]
- Lexik [email protected]
- All contributors
License
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
All versions of data-layer-bundle with dependencies
symfony/security-bundle Version ~2.7|~3.0|~4.0
twig/twig Version ~1.0|~2.0