Skip to main content
Out of the box, GA4 has no concept of AI Commerce. Sessions that arrive from ChatGPT, Gemini, or Perplexity land in Direct and disappear into the noise. The Asva attribution snippet automatically enriches each page view with AI source data — but you need to tell GA4 what to do with that data. This guide walks you through creating the custom dimensions, configuring channel grouping, and building a report so AI Commerce becomes a first-class channel in your analytics.

Before you begin

You need:
  • Admin access to your GA4 property (to create custom dimensions and channel groups)
  • The Asva snippet installed on your storefront (see Surface Hidden AI Traffic with Asva Attribution)
  • Your Asva Property ID from Dashboard → Settings → Property

Set up GA4 custom dimensions and reporting

1

Install the Asva snippet

If the snippet is not yet on your site, add it to your storefront <head>. The snippet automatically enriches page_view events with three parameters GA4 needs:
<script>
  (function(w,d,s,l,i){w[l]=w[l]||[];
  w[l].push({'asva.start': new Date().getTime(), event:'asva.js'});
  var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='asvaLayer'?'&l='+l:'';
  j.async=true;j.src='https://cdn.asva-ai.com/attribution.js?id='+i+dl;
  f.parentNode.insertBefore(j,f);
  })(window,document,'script','asvaLayer','YOUR_PROPERTY_ID');
</script>
The snippet sets:
ParameterValue exampleWhat it means
ai_sourcechatgpt, gemini, perplexityWhich AI surface referred the session
is_ai_sessiontrue / falseWhether Asva classified the session as AI-sourced
ai_confidence0.82Confidence score of the AI classification
2

Create custom dimensions in GA4

GA4 does not recognise ai_source, is_ai_session, or ai_confidence automatically. You must register them as custom dimensions.Go to GA4 Admin → Custom definitions → Custom dimensions and create one dimension for each row below:
Dimension nameScopeEvent parameter
AI SourceSessionai_source
AI SessionSessionis_ai_session
AI Session ConfidenceSessionai_confidence
For each dimension:
  1. Click Create custom dimension
  2. Enter the Dimension name from the table above
  3. Set Scope to Session
  4. Enter the Event parameter from the table above
  5. Click Save
Custom dimensions only populate for data collected after you save them. Historical sessions will not be backfilled, so create your dimensions before expecting to see data.
3

Add an AI Commerce channel group

Create a custom channel group so GA4 labels AI-sourced sessions as “AI Commerce” rather than “Direct”.Go to GA4 Admin → Channel groups → Create new channel group, then add the following rule:
  • Session source/medium contains ai
  • OR custom dimension AI Source is not empty
Name the channel AI Commerce and save. Set it as your default channel group.If you use Looker Studio or query GA4 via BigQuery, use this equivalent CASE expression:
// GA4 Channel Grouping Rule (Looker Studio / BigQuery)
CASE
  WHEN session_default_channel_group = 'Direct'
    AND session_manual_utm_medium IN ('ai', 'chatgpt', 'gemini', 'perplexity')
    THEN 'AI Commerce'
  WHEN session_default_channel_group = 'Direct'
    AND ai_source IS NOT NULL
    THEN 'AI Commerce'
  ELSE session_default_channel_group
END AS channel
4

Build an AI Commerce Exploration report

Create a custom Exploration report to track AI commerce performance alongside your other channels.Go to Explore → Blank exploration and configure:Dimensions to add:
  • Channel group (custom)
  • AI Source
  • Landing page + query string
Metrics to add:
  • Sessions
  • Conversions
  • Conversion rate
  • Total revenue
  • Average order value
Drag Channel group into Rows and all metrics into Values. Add a filter for Channel group exactly matches AI Commerce to isolate the channel.
5

Verify data is flowing

Wait 24–48 hours after installing the snippet for session data to populate, then confirm the integration is working.Browser console check — open your storefront in a browser and run:
// Test in browser console on your site
console.log(window.asvaLayer)
// Should show { ai_source: 'chatgpt', is_ai_session: true, ... }
// if you arrived from a ChatGPT link
GA4 DebugView check:
  1. Append ?asva_debug=1 to any page URL on your store
  2. Open GA4 → DebugView
  3. Look for page_view events with the ai_source parameter populated
What to look for in GA4 reports:
  • AI Commerce appears as a channel in your default channel group breakdown
  • The AI Source dimension shows values like chatgpt, gemini, or perplexity
  • Sessions with is_ai_session = true are visible in the Exploration report

Platform-specific setup

Add the snippet via Online Store → Themes → Edit code → theme.liquid, inside the <head> block:
{% comment %} Asva AI Attribution {% endcomment %}
<script>
  (function(w,d,s,l,i){w[l]=w[l]||[];
  w[l].push({'asva.start': new Date().getTime(), event:'asva.js'});
  var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='asvaLayer'?'&l='+l:'';
  j.async=true;j.src='https://cdn.asva-ai.com/attribution.js?id='+i+dl;
  f.parentNode.insertBefore(j,f);
  })(window,document,'script','asvaLayer','{{ settings.asva_property_id }}');
</script>
Add asva_property_id as a theme setting in your settings_schema.json so you can update the ID without editing code.

Troubleshooting

Custom dimensions only capture data from the moment they are created. If you created the dimensions after the snippet was already live, the data from sessions before creation is not backfilled. Wait 24–48 hours after creating the dimensions to see data appear.
Confirm the channel group rule is saved and set as default. Channel group changes can take up to 48 hours to appear in standard reports. Use DebugView to verify the parameters are firing correctly in real time.
The snippet is either not loading or loading after a navigation event fires. Confirm it is placed inside <head>, not before </body>. Check your browser network tab for a request to cdn.asva-ai.com/attribution.js — a 404 or blocked request indicates an incorrect Property ID or a content security policy blocking the script.
Some AI surfaces strip referrer headers inconsistently. Sessions classified through behavioral fingerprinting (rather than a detected referrer) will have is_ai_session = true but ai_source may be empty. Filter on is_ai_session = true rather than ai_source is not empty to capture all AI Commerce sessions.

Surface Hidden AI Traffic with Asva Attribution

Understand why AI traffic is misattributed and how the Asva snippet works.

How Asva's Attribution Model Works

Learn how Asva classifies sessions using signal tiers and confidence scores.