Tag

A tag is a small piece of client-side code (or a server call) that sends tracking data from your site or app to an analytics or marketing endpoint. When a user triggers an event—a pageview, a click, a form submit—the tag “fires” and transmits a payload so you can measure behavior, conversions, and performance across sessions.

How tags work (quick anatomy)

At runtime, your page loads a tag (script/img/beacon). A condition evaluates; if true, the tag sends a request with parameters (URL query, headers, body). A data layer often supplies clean values (e.g., product_id, price) so tags don’t scrape the DOM. Classic pixel tags use a 1×1 image request; modern ones use navigator.sendBeacon().

ComponentPurposeExample
LoadMake tag code available<script src="/vendor-analytics.js">
ConditionWhen to fireURL contains /checkout
PayloadWhat to send{event:"purchase", value:39.99}

Mini example: a button click fires a tag that POSTs event=purchase&value=39.99&currency=USD&client_id=abc123. Total purchases later = count of event=purchase hits (optionally deduped by order_id).

Why tags matter

  • Attribution & KPIs: Tags power funnels, ROAS, and cohort views.
  • Latency of insight: Cleaner tags → faster, more trustworthy dashboards.
  • Privacy & compliance: Tags control cookies and identifiers; governance matters.

Implementation tips

  • Plan your schema: Decide event names and parameters up front. Keep names stable and lowercase.
  • Centralize via a TMS: A tag manager reduces code deploys and version-controls changes.
  • Use durable keys: Send event_id or order_id to dedupe.
  • Respect performance: Defer non-critical tags; prefer beacon over blocking requests.
  • Test rigorously: Validate payloads, fire conditions, and sampling in dev and staging.

Common pitfalls

  • Duplicate fires: Same click triggers multiple listeners → inflated metrics.
  • DOM scraping: Fragile selectors break during redesigns; prefer data layer.
  • Orphaned tags: Legacy vendors left enabled cause noise and page bloat.
  • UTM chaos: Inconsistent UTM parameters ruin channel reports.