Sign in

GTM Essentials

GTM Essentials

Core Google Tag Manager variables we set up on most accounts — first-party cookie readers, "does it exist" booleans, traffic source / ad placement, and a few page/post/form context values.

Keep the Starter Kit in sync. gtm-starter-kit/ bundles copies of every variable below so it imports self-contained. If you add, rename, or change anything here, update the Starter Kit export too — or the bundled copy will drift.

Quick import

gtm-essentials-variables.json is a GTM container export (documented here). Import it to create all of the variables below at once, filed under a GTM Essentials folder.

  1. GTM → Admin → Import Container.
  2. Choose gtm-essentials-variables.json, select your workspace.
  3. Pick Merge and Rename conflicting so nothing existing is overwritten.
  4. Preview, then Confirm.

Placeholder account/container IDs (0) are remapped into whatever container you import into.

What it creates (24 variables)

First-party cookies1PC - <cookie> (1st-Party Cookie variables):

VariableCookiePlatform
1PC - _fbc_fbcMeta
1PC - _fbp_fbpMeta
1PC - fbclidfbclidMeta
1PC - _gcl_aw_gcl_awGoogle Ads
1PC - _uetmsclkid_uetmsclkidMicrosoft Ads
1PC - _ttp_ttpTikTok
1PC - _twclid_twclidTwitter / X
1PC - li_fat_idli_fat_idLinkedIn

Cookie names are the common defaults for each platform — adjust the name parameter if a site stores a click ID under a different cookie.

Session variables (Custom JS) — each also lives on its own in this repo:

Event deduplication:

  • DLV - gtm.uniqueEventId — Data Layer Variable reading GTM's built-in gtm.uniqueEventId key (a page-local event counter). Exists to feed the variable below.
  • cJS - Custom Event ID — globally unique event ID for Meta Pixel / CAPI deduplication, cached per {{DLV - gtm.uniqueEventId}} so every reference within the same event returns the same ID (cjs-custom-event-id.js).

Page / post / form context (Custom JS):

  • cJS - Page Titledocument.title (cjs-page-title.js).
  • cJS - Post Title — the page's .entry-title / h1, falling back to og:title (cjs-post-title.js).
  • cJS - Post ID — the WordPress post/page ID from the postid-… / page-id-… body class (cjs-post-id.js).
  • cJS - Form ID — the id of the first <form> on the page (cjs-form-id.js). For the submitted form's id, use an Auto-Event Variable (Element ID) on a Form Submission trigger instead.

Built-in variables enabled — the import also switches on GTM's standard built-ins: Click Classes / Element / ID / Target / Text / URL, Event, Form Classes / Element / ID / Target / Text / URL, HTML ID, Page Hostname / Path / URL, and Referrer.

Analytics Client ID is intentionally left out — it has no stable container-export type, so enable it by hand in Configure if you need it (one checkbox).

All Variables Used

Custom Variable NameMeta ParameterGA4 ParameterValue TypeDescription
cJS - Ad Placementad_placementStringCustom JavaScript variable that returns the ad placement for the session.
cJS - Custom Event IDeventID (browser) / event_id (CAPI)StringCustom JavaScript variable that returns a globally unique event ID so Meta deduplicates Pixel and Conversions API copies of the same event.
cJS - Traffic Sourcetraffic_sourceStringCustom JavaScript variable that returns the traffic source for the session.
DLV - currencycurrencycurrencyStringThe currency for the value specified.
DLV - gtm.uniqueEventId— (internal)— (internal)IntegerGTM's built-in page-local event counter. Not sent anywhere — it's the cache key for cJS - Custom Event ID.
DLV - item_categorycontent_categoryitems[].item_categoryStringCategory of the page/product. Optional.
DLV - item_idcontent_idsitems[].item_idArray of integers or stringsProduct IDs associated with the event, such as SKUs.
DLV - item_namecontent_nameitems[].item_nameStringName of the page/product. Optional.
DLV - item_typecontent_type— (no GA4 equivalent)StringEither product or product_group based on the IDs passed in content_ids or contents.
DLV - itemscontentsitems[] arrayArray of objectsArray of JSON objects with product IDs and quantities. id and quantity required.
DLV - num_itemsnum_items— (sum of items[].quantity)IntegerUsed with InitiateCheckout. Number of items when checkout was initiated.
DLV - predicted_ltvpredicted_ltv— (GA4 computes pLTV internally)Integer, floatPredicted lifetime value of a subscriber as defined by the advertiser.
DLV - search_stringsearch_stringsearch_termStringUsed with the Search event. The string entered by the user.
DLV - statusstatusBooleanUsed with CompleteRegistration to show registration status. Optional.
DLV - valuevaluevalueInteger or floatThe value of a user performing this event to the business.
delivery_categoryshipping_tierStringType of delivery for a purchased product: in_store, curbside, or home_delivery.
— (no Meta equivalent)transaction_idStringUnique ID for the transaction. Required for GA4 purchase and refund events.