- Enhanced Ecommerce plugin: allows you a smooth integration with Google Analytics Enhanced Ecommerce.
composer require stefandoorn/google-tag-manager-pluginAdd to the bundle list (config/bundles.php):
GtmPlugin\GtmPlugin::class => ['all' => true],3. Follow installation instructions of required sub bundle (https://github.com/xyNNN/GoogleTagManagerBundle)
Add to your configuration:
google_tag_manager:
enabled: true
id: "GTM-XXXXXX"
autoAppend: falseAnd also configure the features you would like to use from this plugin:
gtm:
inject: true
features:
environment: true
route: true
context: true
events: trueIn case you set autoAppend to false & also disable the inject setting inside this plugin, you have to manage loading of the GTM container yourself.
In case you set autoAppend to false & set inject to true, be aware of the following:
Required output to your HTML (head, body & footer) are done through Sylius Twig Hooks. The following Sylius Twig Hooks are used:
sylius_shop.base.headsylius_shop.base.headersylius_shop.base.offcanvassylius_shop.base#javascripts
You can dump the default configuration using:
bin/console config:dump-reference GtmPluginbin/console assets:install
bin/console sylius:install:assets
bin/console sylius:theme:assets:installenvironment: Send Symfony/Sylius environment to GTMroute: Send Symfony/Sylius route to GTMcontext: Send Sylius context information to GTM (currency, locale, channel)events: See below - allows you to register events easily from inside HTML using JS.
var event = new GaEvent('category');
event.register(action, label, value);Make sure also to listen for this specific event inside your GTM configuration.