Get the plugin via Shopware Store:
18. August 2025 // 16:00
Tutorial: Extend codiverse GTM Plugin for Shopware 6 with decorators
With version 6.3.27 and 6.4.2, we are going to release two important updates for our Google Tag Manager Plugin for Shopware 6.
These updates will add the possibilty to extend our plugin by using the decorator pattern. All our services (Ga4Service, GeneralTagsService, DatalayerService and CustomerTagsService) will now be extensible with custom plugins you create. This also makes sure you do not have to alter our plugin code and do not need to worry about updating the plugin and putting the changes back in every time.
In this post, we'll show you a basic example on how to take advantage of the new functionality.
Scenario: we want to add a new value to the datalayer – the mailadress of the customer should always be present in the datalayer once the customer is logged in. Our plugin currently puts the mailadress in the datalayer only on the checkout/finish page, so this might be some information you want to have before the purchase.
Create basic plugin structure
First, create the plugin structure like you would for any Shopware plugin.

Registering the decorator
The services.xml file is the place where you let Shopware know that you are going to decorate our CustomerTagsService:
Returning the modified tags
After you have determined which tags you want to modify (for this example, it is the return value of our getCustomerTags function), you can just retrieve the plugins original data (e.g. the function original return value) by calling the decorated services function:
// Get original tags from GTM plugin $tags = $this->decoratedService->getCustomerTags($customer, $context);
Now you can add any data and return the modified $tags variable. In our example, it works like this:
// Add customer email if logged in if ($customer && $customer->getEmail()) return $tags;