Kowal Extension Audit for Magento 2
€0.00 €0.00
Kowal Data Layer is a Magento 2 module that combines a structured ecommerce data layer, ready-made Google Tag Manager integrations, and order source attribution. Instead of manually adding scripts to the theme, cart, and checkout, the store gets consistent dataLayer events generated directly from Magento data.
The module covers the entire purchase journey: from list and product views, through the cart and shipping and payment selection, all the way to purchase. At the same time, it records how the customer arrived at the store, so the sales source can be checked not only in an analytics tool, but also directly on the order in Magento.
The solution was designed for production stores. It supports per-store-view configuration, multistore and multilanguage installations, sites using FPC or Varnish, and checkout based on AJAX and REST requests. Analytics errors are isolated and do not block adding a product to the cart, checkout, order placement, or redirecting to the payment provider.
The module is intended for Magento 2 stores that want to:
first_touch and last non-direct source (last_touch) attribution saved in the quote and order.item_id, so product identifiers can match advertising feeds.Kowal Cookie Consent and Consent Mode.var/log/kowal_datalayer.log.user_dataview_item_listselect_itemview_itemadd_to_cartremove_from_cartview_cartadd_to_wishlistbegin_checkoutadd_shipping_infoadd_payment_infopurchasepurchase_testFrom the Magento admin panel, the administrator can download separate JSON files for:
Each package contains the required Data Layer variables, rules, and tags with its own name prefix. This allows the exports to be imported into a single GTM container using Merge mode. After import, you only need to fill in the service identifier, for example Measurement ID, Pixel ID, or Conversion ID, check consent settings, and verify the implementation in GTM Preview.
The purchase_test event is intentionally excluded from advertising conversions. Sales are reported through the proper purchase event, which reduces the risk of double-counting transactions.
The module saves two touchpoints:
first_touch — the first recognized customer source;last_touch — the last non-direct source before purchase.It recognizes UTM parameters, visits from search engines, external referrals, and click identifier types from Google Ads, Microsoft Ads, Meta, TikTok, Pinterest, X, and LinkedIn. Regular navigation between store pages and subsequent direct visits do not overwrite the campaign source.
Attribution is saved in the cart and copied to the order before it is created. The information also goes to the attribution object in the purchase event, so it can be used in GTM, BI tools, or additional integrations.
The module does not store raw gclid, fbclid, ttclid, or other click ID values. It keeps only the type of detected parameter and the resulting source classification. The query string is removed from the saved landing page and referrer.
Referrals from payment routes, callbacks, returns, and success pages are ignored so the payment provider is not incorrectly recognized as the sales source.
The module clears the previous ecommerce object before ecommerce events, enforces numeric types for price, quantity, value, tax, and shipping, limits product lists to a maximum of 200 items, and allows you to maintain a consistent item_id throughout the entire purchase journey.
Product list events carry item_list_id, item_list_name, and index, so product clicks and add-to-cart actions from lists retain the product exposure context.
The configuration can work per store view. The module takes into account currency, localized product and category names, the brand attribute, the configurable product strategy, and the product identifier used in analytics.
This makes it possible to match item_id to the identifiers used in Google Merchant Center, Meta Catalog, or another advertising feed without changing the main event logic.
If the store uses the Kowal Cookie Consent module, Kowal Data Layer can work alongside it without duplicating Google Tag Manager. Cookie Consent remains responsible for consents and GTM, while Data Layer is responsible for preparing ecommerce data and the order source.
The exported advertising tags declare ad_storage, ad_user_data, and ad_personalization requirements. The consent configuration should be verified before publishing the container.
purchase_test and online paymentsThe module supports the purchase_test intermediate page for payments that require sending a helper event before redirecting the customer outside the store. In the configuration, you can indicate payment methods and choose the redirect mode: static URL, URL pattern, or adapter.
For gateways that generate a dynamic transaction URL, for example with an order token, the adapter mode should be used. The module keeps the purchase_test mechanism stable, while the dedicated adapter is responsible only for retrieving the correct payment provider URL.
An analytics module should not be a critical part of the purchase process. That is why Kowal Data Layer catches PHP and JavaScript errors, logs the technical context, and allows Magento to continue sales without interrupting the cart, checkout, order placement, or payment redirect.
Attribution capture also works passively. A failure in source recognition, data saving, or the browser request cannot block the page or the order.
A correct data layer is the foundation of effective analytics and advertising campaigns, but information in an external panel alone is often not enough. Kowal Data Layer combines ecommerce events, GTM configuration, and the source of a specific order in one Magento solution.
The administrator gets control over data mapping and visibility into the sales source, the marketer gets ready-to-use campaign data, and the developer gets a predictable and resilient integration mechanism.
kowal/base module.setup:upgrade, because the module adds attribution fields to the quote and sales_order tables.Kowal_CookieConsent, if the store uses it for GTM and Consent Mode.composer config repositories.kowal-datalayer vcs composer require kowal/module-datalayerphp bin/magento module:enable Kowal_DataLayerphp bin/magento setup:upgradephp bin/magento cache:flush The setup:upgrade command creates the following columns:
quote.kowal_attribution_first;quote.kowal_attribution_last;sales_order.kowal_attribution_first;sales_order.kowal_attribution_last.The columns contain serialized first-touch and last-touch data. They should not be created manually.
Before updating production, make a database backup according to the project procedure. Then update the package and Magento schema:
composer update kowal/module-datalayer --with-dependenciesphp bin/magento module:enable Kowal_DataLayerphp bin/magento setup:upgradephp bin/magento cache:flushIn production mode, run DI compilation and static assets deployment again. This is required, among other things, for the new attribution endpoint, quote/order observers, and changes in the frontend script.
In the production environment, if required by the project, run the standard Magento deployment:
php bin/magento setup:di:compilephp bin/magento setup:static-content:deployphp bin/magento cache:flushAfter the ACL permissions are updated, the administrator may need to log back into the admin panel to see the Data Layer > GTM Exports item.
Admin panel:
Stores > Configuration > Kowal > Kowal Data Layer
Menu:
kowal.store > Modules > Data Layer > Settings
Enable Module - enable the module for the selected configuration scope.Debug Mode - enable only during testing and implementation verification.Render Mode - leave Server and JavaScript unless there is a reason to limit the operating mode.Missing Value Strategy - choose whether missing values should be skipped or sent as undefined.Clear Ecommerce Before Push - recommended Yes.Fail-safe Mode - recommended Yes; sales-critical processes remain protected even if this option is disabled.Log Level - Errors only is recommended in production.Log Payloads - enable only temporarily.Product Identifier Attribute - choose the attribute used as item_id. Default: sku.Brand Attribute - choose the manufacturer/brand attribute. Default: manufacturer.Category Strategy - choose the method for building item_category.Category Attribute - set only if the category strategy uses a product attribute.Configurable Product Strategy - decide whether to use child/simple or parent/configurable data.Include Out Of Stock Products On Lists - applies to product list events.Enable the events required by the implementation:
user_dataview_item_listselect_itemview_itemadd_to_cartremove_from_cartview_cartadd_to_wishlistbegin_checkoutadd_shipping_infoadd_payment_infopurchasepurchase_test, if the store uses the intermediate page before payment.Send User ID - sends the Magento customer ID for logged-in customers.Send Hashed Email - sends only the SHA-256 hash of the email. The raw email does not go to dataLayer.Capture First and Last Touch Attribution saves the customer's entry source in the quote and order. Recommended setting: Yes.
The setting works per store view. After disabling it, the module does not register new touchpoints. Data previously saved in existing orders remains in the database.
The module recognizes:
utm_source, utm_medium, utm_campaign, utm_id, utm_term, utm_content, and utm_source_platform parameters;It saves first_touch and last_touch, meaning the last non-direct source. Regular navigation between store pages does not overwrite the source. Referrals from payment addresses, callbacks, returns, and success pages are ignored so the payment provider is not recognized as the sales source.
Capture works in two ways:
The data is kept in the checkout session, saved with the quote, and copied to the order before order placement. The mechanism covers the classic frontend, AJAX/REST checkout, and orders created from a quote that already contains attribution.
Raw gclid, fbclid, and other click identifier values are not stored. The module keeps only the parameter type, for example gclid, and the resulting source classification. Query strings are removed from the saved landing page and referrer.
You can verify attribution:
Customer Attribution section;dataLayer under the attribution property of the purchase event;kowal_attribution_first and kowal_attribution_last columns of the quote and sales_order tables.Source capture should be included in the store's privacy documentation according to the implementation policy. The module does not create its own long-term user identifier and does not store click ID values, but it does store campaign metadata and the order source.
Integrate With Kowal Cookie Consent - enable if the store uses Kowal_CookieConsent.Render GTM From DataLayer Module - leave No if GTM is already rendered by Cookie Consent or another module.Google Tag Manager ID - set only if rendering GTM from this module is enabled.purchase_test Redirect Rules - add only those payment methods that should use the purchase_test intermediate page.purchase_test rule modes:
Static URL - use only for payments with a fixed payment provider address.URL Pattern - use when a URL pattern with {order_id}, {order_increment_id}, {store_id}, or {quote_id} placeholders is sufficient.Adapter Required - use for gateways that generate a dynamic transaction URL. Before launching in production, a dedicated adapter must be added for the specific payment module.Configure the module at the store view level if the stores differ in:
dataLayer in the browser console or with the DataLayer Checker extension.view_item event.view_item_list.select_item.add_to_cart.remove_from_cart.add_to_wishlist.view_cart and begin_checkout.add_shipping_info and add_payment_info.purchase.purchase is not duplicated.var/log/kowal_datalayer.log.?utm_source=test&utm_medium=cpc&utm_campaign=attribution_test.Customer Attribution section and attribution.first_touch and attribution.last_touch in the purchase event.first_touch.source has the value test, medium has the value cpc, and campaign has the value attribution_test.first_touch remained unchanged and last_touch was updated.In the Magento admin panel, go to Kowal > Data Layer > GTM Exports. Separate packages are available for GA4, Google Ads, Meta, TikTok, Pinterest, and Microsoft Ads.
Admin > Import Container.Merge mode.Element names are prefixed with Kowal - platform name, which allows the packages to be combined in one container. The purchase_test event is not exported as a conversion; sales are reported exclusively through purchase.
After import, fill in the following constant variables:
| Export | Required value |
|---|---|
| GA4 | Measurement ID in the format G-XXXXXXXXXX |
| Google Ads | Conversion ID AW-XXXXXXXXX and the purchase conversion label |
| Meta | Pixel ID |
| TikTok | Pixel ID |
| Tag ID | |
| Microsoft Ads | UET Tag ID |
The exports apply to the web container and browser-side delivery. They do not replace server-side integrations such as Meta Conversions API or TikTok Events API.
ad_storage, ad_user_data, and ad_personalization.Kowal_CookieConsent, leave Render GTM From DataLayer Module set to No.purchase_test integrationIf a payment method redirects the customer outside the store and knows the target payment provider URL, the payment integration can use:
Kowal\DataLayer\Model\PurchaseTestRedirect::prepare($paymentRedirectUrl)The method returns the module's intermediate page URL. The intermediate page sends purchase_test and then redirects the customer to the payment provider. If JavaScript or DataLayer does not work, the redirect should still be performed.
For an integration where the URL depends on the order or transaction token, use:
Kowal\DataLayer\Model\PurchaseTestRedirect::prepareForOrder($order, $fallbackRedirectUrl)If the method is set to Adapter Required mode, the adapter should implement:
Kowal\DataLayer\Api\PurchaseTestRedirectAdapterInterfaceThe adapter should be registered in DI as an adapters array element for Kowal\DataLayer\Model\PurchaseTest\RedirectAdapterPool. The adapter is the right place for logic dependent on a specific payment provider.
Capture First and Last Touch Attribution is enabled for the correct store view.php bin/magento setup:upgrade was run and that the four attribution columns exist.var/log/kowal_datalayer.log for attribution capture failed or attribution assignment failed messages.kowal_datalayer/attribution/capture in developer tools.200 and is sent to the same store domain.view/frontend/web/js/data-layer.js file was published.Check whether the order was created from a quote containing attribution before the redirect. Routes containing payment, callback, return, or success should not overwrite last-touch with a referral. If a custom payment module uses a different sequence, verify when the order is created and the quote is saved.
Use Merge mode and review the change details. Export elements use the Kowal - ... prefix; if the container contains modified elements with the same name, deliberately choose overwrite or rename them. After renaming, check tag references to variables and triggers.