DataSag guides · Updated 27 October 2026
Track UTM campaigns on your website
Add utm_source, utm_medium and utm_campaign to the external link that sends visitors to your site. DataSag reads these parameters from the current page URL when building tracking payloads.
Before you start
Install the DataSag script once on the pages you intend to measure. Use the public key from the project you are inspecting. Publish your change, then test the public domain rather than relying on an editor preview.
Account credentials, database credentials and provider API keys do not belong in the tracking snippet. Keep existing consent controls in place. Report availability depends on your current plan and provider connections.
Track UTM campaigns: step by step
- Choose a naming convention before distributing links. Use a source for the publisher, a medium for the channel and a campaign for the specific launch or promotion.
- Build the destination with URL and URLSearchParams so spaces and punctuation are encoded. Preserve any existing required parameters.
- Open the complete link in a new visit. Confirm that redirects and link shorteners preserve the parameters all the way to the final landing URL.
- Inspect the initial /api/track payload for utmSource, utmMedium and utmCampaign. Compare exact strings, including capitalization, with your naming sheet.
- Inspect the campaign report available to your plan. The current page URL is the collection source; do not assume parameters persist onto untagged later pages or imply multi-touch attribution.
- Keep UTM tags on incoming campaign links. Tagging every internal navigation link changes the meaning of a campaign and makes acquisition analysis harder.
const landing = new URL('https://example.com/launch');
landing.searchParams.set('utm_source', 'newsletter');
landing.searchParams.set('utm_medium', 'email');
landing.searchParams.set('utm_campaign', 'autumn_launch');
console.log(landing.href);What a successful check looks like
The final landing URL retains all three tags and the initial pageview payload contains the same values. Consistent spelling produces comparable campaign groups.
Record the tested URL, date, browser state and observed request. Repeat on a nested page to check the shared installation. Keep the evidence so you can distinguish a later regression from a report-filter change.
Common mistake
UTM labels are supplied by whoever creates the link. A label such as utm_source=chatgpt is not independent evidence that an AI assistant recommended your site.
Find your platform's installation point
- Next.js App Router
- Next.js Pages Router
- React with Vite
- Astro
- SvelteKit
- Nuxt
- WordPress
- Webflow
- Framer
- Shopify storefront themes
- Squarespace
- HTML websites
- Laravel Blade
- Django templates
- Flask with Jinja
- Ruby on Rails
- Express with EJS
- Remix v2
- Angular
- Vue with Vite
- Standalone Blazor WebAssembly
- PHP templates
- Gatsby
- Hugo
- Ghost
- Carrd
- Docusaurus
- VitePress
- Material for MkDocs
- Jekyll
- Eleventy
- Hexo
- Pelican
- Grav 1.7 Twig themes
- Drupal Twig themes