Analytics & Ad Tracking
How to Track Ad Traffic with UTM Parameters
Install the Koursely UTM tracking script on your landing page so every student's campaign source, ad set, medium, and placement is automatically captured and visible in the Ad Tracker dashboard.
What This Does
When a visitor lands on your website through an ad (Facebook, Google, Instagram, YouTube, WhatsApp, etc.), the ad platform appends special tracking tags to your URL — called UTM parameters. For example:
https://yoursite.com/landing?utm_source=facebook&utm_medium=paid_social&utm_campaign=summer_sale&placement=feed&adset_name=age_25_35
The tracking script reads these tags the moment a visitor lands, saves them to the browser's session memory, and automatically forwards them to every link the visitor clicks — including your Koursely signup/checkout links. When the student registers, Koursely captures and stores those parameters against their profile, making them visible in the Ad Tracker dashboard under Revenue → Ad Tracker.
Supported Tracking Parameters
Use these exact parameter names when setting up your ad campaigns:
| Parameter | Source | Example Value | What It Tracks |
|---|---|---|---|
utm_source | Standard UTM | facebook, google, instagram | The ad platform or traffic source |
utm_medium | Standard UTM | paid_social, cpc, email | The marketing channel type |
utm_campaign | Standard UTM | summer_launch_2024 | The campaign name you set in the ad platform |
utm_content | Standard UTM | video_ad_v1, carousel_3 | The specific creative or ad variant |
placement | Meta / Facebook | feed, reels, stories | Where the ad was shown (Meta-specific) |
adset_name | Meta / Facebook | lookalike_buyers_india | The ad set / audience group name |
Meta / Facebook Ads tip: Add placement={{placement}} and adset_name={{adset.name}} under URL Parameters in your campaign settings. Meta replaces these at serving time with the actual values (e.g. reels, stories).
Step 1 — Install the Tracking Script on Your Landing Page
Copy the complete script below and paste it into the <head> section of your landing page, before the closing </head> tag. It is a single self-contained snippet — no libraries or dependencies required.
<script>
(function () {
var trackingParams = [
"utm_source",
"utm_medium",
"utm_campaign",
"utm_content",
"placement",
"adset_name"
];
var currentUrlParams = new URLSearchParams(window.location.search);
trackingParams.forEach(function (param) {
var value = currentUrlParams.get(param);
if (value) { sessionStorage.setItem(param, value); }
});
function getStoredTrackingParams() {
var params = new URLSearchParams();
trackingParams.forEach(function (param) {
var value = sessionStorage.getItem(param);
if (value) { params.set(param, value); }
});
return params;
}
function appendTrackingToLinks() {
var storedParams = getStoredTrackingParams();
if (!storedParams.toString()) return;
var links = document.querySelectorAll("a[href]");
links.forEach(function (link) {
var href = link.getAttribute("href");
if (!href || href.startsWith("#") || href.startsWith("tel:") ||
href.startsWith("mailto:") || href.startsWith("javascript:")) return;
try {
var linkUrl = new URL(href, window.location.origin);
var linkParams = new URLSearchParams(linkUrl.search);
storedParams.forEach(function (value, key) {
if (!linkParams.has(key)) { linkParams.set(key, value); }
});
linkUrl.search = linkParams.toString();
link.setAttribute("href", linkUrl.toString());
} catch (e) { console.warn("Could not update link:", href); }
});
}
document.addEventListener("DOMContentLoaded", appendTrackingToLinks);
setTimeout(appendTrackingToLinks, 1000);
setTimeout(appendTrackingToLinks, 3000);
})();
</script>
Platform-specific installation
WordPress
- Install the Insert Headers and Footers plugin.
- Go to Settings → Insert Headers and Footers.
- Paste the script in the Scripts in Header box and save.
Webflow
- Open Project Settings → Custom Code tab.
- Paste the script in Head Code and publish.
Wix
- Go to Settings → Custom Code → Add Custom Code.
- Paste the script, set placement to Head, apply to All Pages, and save.
Squarespace
- Go to Settings → Advanced → Code Injection.
- Paste the script in the Header field and save.
ClickFunnels / GoHighLevel
- Edit the page → Page Settings → Header Scripts.
- Paste the script, save, and republish.
Google Tag Manager (any builder)
- Create a new Custom HTML tag in GTM.
- Paste the script (including the script tags).
- Trigger: All Pages → Page View. Submit and publish.
Step 2 — Set Up Your Campaign URLs
Google Ads — Tracking Template
{lpurl}?utm_source=google&utm_medium=cpc&utm_campaign={campaign.name}
Meta / Facebook Ads — URL Parameters Field
In Ad Set → Destination → URL Parameters, add:
utm_source=facebook&utm_medium=paid_social&utm_campaign={{campaign.name}}&utm_content={{ad.name}}&placement={{placement}}&adset_name={{adset.name}}
Example correctly tagged URL
https://yoursite.com/landing?utm_source=facebook&utm_medium=paid_social&utm_campaign=q3_launch&placement=reels&adset_name=lookalike_buyers_india
When a student clicks this link and signs up on Koursely, all 5 parameters appear on their profile in the Ad Tracker.
Step 3 — Verify the Setup
- Test URL: Visit your landing page with UTM params:
https://yoursite.com/landing?utm_source=test&utm_medium=manual&utm_campaign=verify - Check sessionStorage: Open DevTools (F12) → Application → Session Storage. You should see
utm_source,utm_medium,utm_campaignkeys with your values. - Inspect a signup link: Click any signup button — the destination URL should now include your UTM parameters.
- Test registration: Register as a test student. Open Revenue → Ad Tracker and search for the test email. The UTM columns should show the values you set.
FAQ
What if a student visits multiple pages before signing up?
sessionStorage persists for the entire browser session. UTM parameters captured on the first landing page are forwarded to every link clicked within the same session, including the final signup page.
Will this slow down my landing page?
No. The script is tiny (~2 KB), makes no external network requests, and runs asynchronously. There is zero impact on page speed or Core Web Vitals.
What if the student uses a different device to sign up?
sessionStorage is device and browser specific. If a student clicks the ad on mobile but registers on desktop, the UTM data will not carry over. This is a standard limitation of all client-side tracking approaches.
Can I add more parameters to track?
Yes — add any parameter name to the trackingParams array in the script (e.g. "utm_term", "gclid"). Note that Koursely's Ad Tracker currently surfaces the 6 built-in parameters as columns; other parameters will be forwarded to links but may not display as columns in the dashboard.
Do I need this on every page?
Only on pages where ads land. Adding it to all pages is harmless but unnecessary — the script does nothing if no UTM parameters are present in the URL.
Was this article helpful?