lexik/data-layer-bundle
Lexik DataLayerBundle provides a flexible data layer abstraction for Symfony applications, letting you organize and query business data through configurable layers. Lightweight, easy to integrate, and maintained by Lexik.
dataLayer payload in PHP and render it in Twig, instead of hand-writing JSON blobs across templates. That is the technical enabler for the real product decision: whether we standardize an event taxonomy (e.g. view_item, add_to_cart, begin_checkout, purchase) rather than letting each squad invent its own keys.DataLayer service, and do we vendor this or write our own?"dataLayer.push calls make attribution and conversion reporting unreliable and A/B test bucketing inconsistent.@inertia/view composer) writing a JSON-encoded layer. Do not let a low-effort wrapper drive a framework decision.Consider it when:
Look elsewhere when:
DataLayer service, a facade, and a Blade partial instead.dataLayer helper does not address that architecture.For executives: This is a small Symfony helper for sending structured event data to Google Tag Manager. The strategic value is not the library — it is the pattern: one governed place where we define what we measure, so marketing, growth, and finance report off the same numbers. The package itself is a 2018 artifact with trivial adoption and no community; I would not fund it as a dependency. I would fund a short instrumentation initiative — an event taxonomy, a consent gate, and a small internal service — and use this repository as a reference for the shape. The measurable payoff is trustworthy funnel and attribution reporting and a defensible consent posture; the cost is roughly one engineer-week and no ongoing vendor risk.
For engineering: This is a thin, unmaintained Symfony bundle that collects an array in a service and renders it into a dataLayer script tag via Twig. Last release Feb 2018, 14 stars, no dependents — treat it as read-only reference, not a composer require. If we are on Symfony, spike it in a branch against our actual Symfony/PHP versions before committing, and expect to fork the Twig extension. If we are on Laravel — which we are — it does not apply at all: we write a DataLayer service with a push()/render() contract, a Blade partial that emits the JSON, and a DataLayerFake for tests. The genuinely hard parts are not the wiring: they are (1) an event schema with validation so bad events fail loudly in CI rather than silently in GTM, (2) consent gating before any marketing tags fire, and (3) a review step so product and marketing cannot add untyped keys ad hoc. Recommend a one-week time-boxed spike covering the service, a schema test, and one instrumented funnel step, then decide on scope.
How can I help you explore Laravel packages today?