Analytics & Tags
Google Tag Manager is the single integration point for analytics and marketing tags on your storefront. Set your container ID as a store setting and the container loads, with no redeploy and no involvement from us. Google Analytics 4, ad platform tags and consent tooling are all configured inside GTM.
Connect Google Tag Manager
Set gtmId in the evolve_gtm namespace. See Store Settings for the mechanics.
curl -X POST 'https://api.bigcommerce.com/stores/{store_hash}/v3/channels/{channel_id}/metafields' \
-H 'X-Auth-Token: {management_api_token}' \
-H 'Content-Type: application/json' \
-d '{
"namespace": "evolve_gtm",
"key": "gtmId",
"value": "GTM-XXXXXXX",
"permission_set": "read_and_sf_access",
"description": "Google Tag Manager container"
}'
Until gtmId is set, no tag manager script is loaded at all. There is no separate setting for a GA4 measurement ID. Configure GA4 as a tag inside your container.
Settings
| Setting | Type | Default | What it does |
|---|---|---|---|
gtmId | text | empty | Your container ID, e.g. GTM-XXXXXXX |
gtmAuth | text | empty | Environment auth string, if you use GTM environments |
gtmPreview | text | empty | Environment preview name, e.g. env-3 |
marketingParameters | JSON | see below | Maps incoming URL query parameters to the attribution values captured |
marketingTimeStamp | text | utm_timestamp | Name the campaign timestamp is captured under |
GTM environments
To point your storefront at a GTM environment rather than the live container, set gtmAuth and gtmPreview alongside gtmId. Take all three values from Admin → Environments → Get snippet in GTM.
Consent
Run your consent banner as a tag inside GTM, using whichever consent management platform you already use. GTM's own consent mode then governs when your other tags are allowed to fire. Your storefront has no separate consent setting of its own.
Marketing attribution
Campaign parameters on an incoming URL are captured, stored in the shopper's browser for the rest of their visit, and attached to every data layer event after that. The default mapping:
{
"utm_source": "utm_source",
"utm_medium": "utm_medium",
"utm_campaign": "utm_campaign",
"utm_term": "utm_term",
"utm_content": "utm_content",
"affiliate_ref": "ref"
}
Read each pair right to left: the value is the query parameter to look for on the URL, and the key is the name it's captured and reported under. So "affiliate_ref": "ref" picks up ?ref= and reports it as affiliate_ref. To add your own parameter, set the whole object. It replaces the default rather than merging with it:
curl -X POST 'https://api.bigcommerce.com/stores/{store_hash}/v3/channels/{channel_id}/metafields' \
-H 'X-Auth-Token: {management_api_token}' \
-H 'Content-Type: application/json' \
-d '{
"namespace": "evolve_gtm",
"key": "marketingParameters",
"value": "{\"utm_source\":\"utm_source\",\"utm_medium\":\"utm_medium\",\"utm_campaign\":\"utm_campaign\",\"partner_id\":\"partner\"}",
"permission_set": "read_and_sf_access"
}'
Events available to your tags
Your storefront pushes these events to the data layer as shoppers move through the site. Build your GA4 or ad platform tags on top of them.
| Event | Fires when |
|---|---|
| Product view | A shopper opens a product page |
| Product click | A shopper selects a product from a listing |
| Item list view | A category or listing page renders its products |
| Search results view | A search returns results |
| Cart view | The cart page opens |
| Add to cart | An item is added |
| Remove from cart | An item is removed |
| Checkout | A shopper starts checkout |
| Promotion view | A promotion is displayed |
| Promotion click | A shopper selects a promotion |
Because checkout runs on BigCommerce, the payment, shipping and purchase steps happen on BigCommerce's pages, not yours. Those events are not emitted by your storefront. Configure purchase and revenue tracking in BigCommerce, either through its own analytics settings or with a GTM container on the BigCommerce checkout. Without that, your funnel will end at checkout start and report no revenue.
Use the same GA4 property from both sides so sessions stitch together, and test the full funnel with a real order before you trust the numbers.
Other tags and scripts
Add tags through GTM. It covers ad pixels, heatmaps, chat widgets, A/B testing and consent tooling, and it needs no changes from us.
Two cases do need us:
- A script that must load before the page renders, ahead of GTM. Rare, but some personalization and anti-flicker snippets require it.
- A third-party domain that the browser blocks. Your storefront sends a Content Security Policy header, so a script served from a domain we don't yet allow will be refused by the browser. If a tag installed through GTM doesn't run and your browser console shows a Content Security Policy error, tell us the domain and we'll allow it.
See also
- Store Settings — how to set a setting
- SEO — metadata and Open Graph
- Shopper Accounts & Checkout — what BigCommerce owns