Sub topic 8
Testing tagged links with Realtime and DebugView
You have built a tagged URL. Before it goes into an email, an ad or a social post, confirm that the tags survive the trip to your site and that GA4 reads them as intended. Standard reports can lag by a day or more, so a mistake found there may already have cost you a day of misattributed traffic. This chapter covers the two tools that give feedback in seconds: the Realtime report and DebugView.
It assumes you have a GA4 property with a web data stream installed, you can open its reports, and you know how a query string works. You should also know the three core parameters (utm_source, utm_medium, utm_campaign) and the naming convention your team uses.
What each tool answers
The two tools answer different questions, so use them together.
| Tool | Question it answers | Scope | Latency |
|---|---|---|---|
| Browser console or redirect check | Did the UTM parameters reach the landing page? | One browser, before GA4 | Instant |
| Realtime report | Did GA4 record a visit with the source, medium and campaign I expect? | All users in the last 30 minutes | Seconds |
| DebugView | What exact events and parameters did my device send? | One debug-enabled device | Seconds |
| Standard reports | Does the campaign appear correctly in aggregate? | All data | Hours to a day or more |
Test in that order. Each step rules out a class of problem, so a failure at one step tells you where to look.
Step 1: Check the landing page URL
GA4 reads campaign values from the page URL that the browser reports. If a redirect, a link shortener or a server rule strips the query string, GA4 never sees the UTM parameters. Checking this first removes the most common failure before you open GA4.
Open the tagged link in a private window. Then open the browser console on the landing page and run the snippet below.
const params = new URLSearchParams(window.location.search);
const utm = Object.fromEntries(
[...params].filter(([key]) => key.startsWith('utm_'))
);
console.log(utm);
// { utm_source: 'newsletter', utm_medium: 'email', utm_campaign: 'spring_sale_2026', ... }An empty object {} means the parameters were lost before the page loaded. Single-page applications can also rewrite the URL after load, so check the address bar and the console output at the moment the first page_view fires, not several navigations later.
Tracing redirect chains
When the console shows nothing, find which hop dropped the parameters. This Node.js script (version 18 or later, saved as trace-redirects.mjs) follows each redirect manually and reports whether the utm_ keys are still present.
// Usage: node trace-redirects.mjs "https://example.com/go?utm_source=newsletter&utm_medium=email&utm_campaign=spring_sale_2026"
const startUrl = process.argv[2];
if (!startUrl) {
console.error('Pass a URL as the first argument');
process.exit(1);
}
const utmKeys = (u) =>
[...new URL(u).searchParams.keys()].filter((k) => k.startsWith('utm_'));
let url = startUrl;
for (let hop = 0; hop < 10; hop++) {
const res = await fetch(url, { redirect: 'manual' });
console.log(`${hop}: ${res.status} ${url}`);
console.log(` utm keys: ${utmKeys(url).join(', ') || '(none)'}`);
const location = res.headers.get('location');
if (res.status >= 300 && res.status < 400 && location) {
url = new URL(location, url).toString();
} else {
console.log('Final page reached.');
break;
}
}The first hop that prints (none) after a hop that had keys is the one that strips them. Typical causes are an HTTP-to-HTTPS redirect rule, a trailing-slash redirect that rebuilds the URL, or a login wall that redirects to a fixed address.
Step 2: Confirm the hit in the Realtime report
The Realtime report shows activity from the last 30 minutes, usually within seconds of it happening. Open it from Reports > Realtime.
Look for three things:
- The visit appears at all. The user count rises by one when you load the page. If it does not, the tag may not be firing. Skip ahead to DebugView.
- The traffic source card lists the source you tagged. The card's name and its attribution scope (first user or session) have varied between GA4 interface versions. Read the card title. If it shows first user source and your test device has visited before, you see the original source, not the new one.
- The event and page cards show the landing page. This confirms the visit reached the page you intended.
You can also add a comparison or filter. For example, set a filter on a campaign dimension to isolate your test from other live traffic. The dimensions available in Realtime are limited, and the exact set depends on the interface version. If the campaign name you need is not listed, use DebugView for the full detail.
Make the test a clean test
Several things cause a correct link to look wrong in Realtime.
- An existing session. If your browser already has an active GA4 session, a tagged click may not be treated as the start of a new one, so the session keeps its earlier source. Use a fresh private window, or wait for the 30-minute inactivity timeout to pass.
- A returning user. Cookies from earlier visits keep the first-user attribution. A private window creates a new client ID, which solves this.
- Ad blockers and privacy extensions. They can block the GA4 request. Disable them or test in a clean profile.
- Consent settings. If a consent banner denies analytics storage, the data collected may be limited or cookieless. Accept analytics consent for the test.
- Data filters. An active internal traffic filter excludes your own visits from reports. Test from a network outside the filtered range, or check the filter state in Admin > Data collection and modification > Data filters.
Step 3: Inspect the events in DebugView
DebugView streams events from devices that are in debug mode, one event at a time, with every parameter. Open it from Admin > Data display > DebugView. It answers whether GA4 received a page_view, and what URL that event carried.
Turn on debug mode
You have several options.
- Tag Assistant. Open [tagassistant.google.com](https://tagassistant.google.com), connect your site and browse. Tag Assistant enables debug mode for that session.
- Google Tag Manager preview. Preview mode of a GTM container also routes events to DebugView.
- The
debug_modeparameter. Add it to the configuration of a gtag.js install:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', { debug_mode: true });
</script>Replace G-XXXXXXXXXX with your measurement ID, and remove debug_mode before release unless you want all traffic marked as debug.
Read the page_view event
In DebugView, the left column is the device selector and the middle is a timeline of events. Click the page_view event, which usually follows session_start and first_visit for a new user. In its parameter list, check these:
page_locationis the full URL GA4 received. It must contain yourutm_source,utm_mediumandutm_campaign. This is the key check. If the parameters are in the browser address bar but not here, something changed the URL before the tag read it.page_referrershows the previous page. A value from your own domain on a click that should have been external points to a self-referral problem, which the pitfalls chapter covers.ga_session_idandga_session_numbershow whether this was a new session. A new session number on a returning client explains why first-user and session attribution differ.
DebugView shows the raw event, not the final source/medium. GA4 derives those values during processing from page_location, the referrer and any auto-tagging click ID. So DebugView proves what was sent, and the reports show what GA4 concluded.
Interpreting the results
Use the combination of observations to decide what is wrong.
| Observation | Likely cause | Fix |
|---|---|---|
| No `utm_` keys on the landing page | A redirect or link shortener stripped them | Trace the chain, then fix the rule that drops the query string |
| `utm_` keys on the page, absent from `page_location` | Script rewrites the URL before the tag reads it | Load the tag earlier, or stop the rewrite |
| `page_location` correct, Realtime shows the old source | Existing session or returning user | Retest in a private window |
| No events in DebugView | Debug mode not enabled, tag blocked, or consent denied | Check Tag Assistant, disable blockers, accept consent |
| Realtime source is `(direct) / (none)` despite UTMs | Parameters lost, or the visit is a continuing session | Check `page_location` in DebugView |
| Values are right but capitalised differently | Case-sensitive values created a duplicate | Fix the link and apply the naming convention |
| Source and medium are right, channel is Unassigned | The medium does not match a default channel rule | Rename the medium to a recognised value or add a custom channel group |
Values are case-sensitive in GA4, so Email and email are separate rows. Spot a capitalisation problem now, because data already collected cannot be rewritten.
A repeatable pre-launch checklist
Run this for each new link pattern, not each individual link. If every link comes from the same builder function, test one representative link per channel and destination.
- Build the URL with your helper so the values follow the naming convention.
- Open it in a private window with extensions off.
- Confirm the
utm_keys in the console, and use the redirect tracer if you find none. - Watch Realtime for the expected source and campaign.
- Open DebugView and confirm
page_locationon thepage_viewevent. - Record the link and the result in your campaign log.
- After processing finishes, check the same campaign in the acquisition reports and confirm the channel group.
Exercise
You open a tagged link in your normal browser. The landing page URL contains all three UTM parameters, but Realtime shows the visit under your old, earlier source. DebugView shows a page_view whose page_location has the correct UTM values. What most likely happened, and what do you do?
Show answer
GA4 received the correct URL, so the tagging is fine. The old source appears because your browser has an existing session or a returning client ID, so the visit kept earlier attribution. Retest in a fresh private window (or after the 30-minute session timeout) to get a new client and session.
Exercise
The browser console on the landing page prints {} for the UTM parameters, but the link you clicked clearly contained them. Which tool do you use next, and what are two likely causes?
Show answer
Use the redirect tracer (or the browser network panel) to follow each hop and find where the utm_ keys disappear. Likely causes include a redirect or link shortener that drops the query string, an HTTP-to-HTTPS or trailing-slash rule that rebuilds the URL without it, or a login redirect to a fixed address.
Exercise
Why can DebugView show a correct page_location while the acquisition report later shows the campaign in the Unassigned channel?
Show answer
DebugView shows only the raw event that was sent. GA4 derives source, medium and the default channel group later during processing. If the medium (for example mail instead of email) does not match a default channel rule, the traffic is grouped as Unassigned even though the UTM parameters arrived intact. Fix the medium value in the link or define a custom channel group.