Sub topic 2
How social media visitors reach your site
This chapter assumes you know what a URL and its query string are, and that you can read basic HTML and JavaScript. It covers what happens between a tap on a social post and the first page view on your site. Later chapters depend on this, because every attribution error you meet later starts with a visit that arrived in an odd way.
What you will learn
- How the browser reports where a visitor came from, and why that report is often incomplete.
- Which hosts and in-app browsers social platforms use.
- Which kinds of social visits are likely to be labelled "direct", and why.
- How to inspect a real visit to see what your site received.
The referrer: the browser's report of where a click came from
When a visitor follows a link, the browser can attach a request header named Referer (the misspelling is historical and permanent). In JavaScript, the same value is available as document.referrer.
GET /spring-sale HTTP/1.1
Host: example.com
Referer: https://l.instagram.com/Analytics tools read this value and turn it into a session source. In GA4, a visit with referrer l.instagram.com and no other tagging usually appears as source l.instagram.com, medium referral, unless GA4 recognizes the host as a social site.
Three rules limit how useful the referrer is:
- It is a hint, not a record. The sender, the browser, or the page can change or remove it.
- Browsers trim it. Modern browsers default to
strict-origin-when-cross-origin. A cross-site visit therefore sends only the origin (https://l.instagram.com/), not the path. You will never see which post the visitor clicked from the referrer alone. - It disappears in some cases. A link or page can set
rel="noreferrer"or aReferrer-Policy: no-referrerheader. Following a link from a secure page to an insecure one also drops it. Native apps often send no referrer at all.
Because of rule 2, the referrer can tell you which platform but almost never which campaign, ad, or post. That job belongs to the UTM parameters in the next chapter.
Link wrappers and redirectors
Social platforms rarely link straight to your page. They send the click through their own redirect service. This lets them warn about unsafe links, count clicks, and control what referrer is sent.
| Platform | Typical referrer host you may see |
|---|---|
| `l.facebook.com`, `lm.facebook.com`, `m.facebook.com`, `facebook.com` | |
| `l.instagram.com` | |
| X (Twitter) | `t.co` |
| `lnkd.in`, `linkedin.com`, `www.linkedin.com` | |
| `out.reddit.com`, `www.reddit.com` | |
| YouTube | `youtube.com`, `m.youtube.com` |
| `pinterest.com`, country subdomains such as `uk.pinterest.com` |
Treat this table as a starting point. Platforms change their redirect hosts, so check the referrers in your own data rather than trusting a static list.
Two consequences follow:
- One platform shows up under several source names. Facebook traffic may be split across
facebook.com,m.facebook.com, andl.facebook.comin a report until you group them. GA4 maps many known social hosts to a single social source in its default channel grouping, but not every variant. - Your own links may be rewritten. Platforms shorten and wrap your URL. They may also append their own click ID, such as
fbclidon Facebook links. Your original query string, including UTM parameters, normally survives, but you should confirm that with a test click.
In-app browsers
Most social apps do not hand your link to Safari or Chrome. They open it in an in-app browser, a web view embedded inside the app. This has practical effects for tracking:
- Separate storage. An in-app browser usually has its own cookies and local storage, apart from the visitor's normal browser. A visitor who is logged in or already has a GA4 cookie in Chrome looks like a new user inside Instagram.
- Split journeys. If the visitor taps "Open in browser" later, or returns by typing your address, the second visit starts a new session with a different client ID. The first visit gets the social credit, and the return visit is likely to show as direct.
- Behavior differences. Some in-app browsers restrict pop-ups, file downloads, payment wallets, or login with Google. Conversion rates can look worse on social for reasons that have nothing to do with the content.
- Variable referrer behavior. Some in-app browsers send a referrer and some do not. This differs by app, operating system, and version, and it changes over time.
You can often recognize an in-app browser from the User-Agent string. The tokens below are common, but they are not guaranteed, so use them for analysis, not for blocking anyone.
function describeVisit() {
const ua = navigator.userAgent;
const inAppPattern = /Instagram|FBAN|FBAV|FB_IAB|LinkedInApp|BytedanceWebview|musical_ly|Snapchat/i;
let referrerHost = '';
if (document.referrer) {
try {
referrerHost = new URL(document.referrer).hostname;
} catch (e) {
referrerHost = '(unparseable)';
}
}
const params = new URLSearchParams(window.location.search);
return {
referrerHost: referrerHost || '(none)',
inAppBrowser: inAppPattern.test(ua),
utmSource: params.get('utm_source') || '(none)',
hasFbclid: params.has('fbclid')
};
}
console.log(describeVisit());To use this, paste it into a page on your own site, or into the browser console on a page you control. Then open that page from a post or message in each app you care about. On a phone you can show the result in the page with document.body.textContent = JSON.stringify(describeVisit(), null, 2);, because there is no console in most in-app browsers.
Why social visits end up as "direct"
GA4 labels a session direct when it has no usable referrer and no campaign tagging. Social traffic ends up there more often than most people expect. The main causes are:
- Untagged links in apps that send no referrer. This is the largest cause. Untagged organic posts in several native apps arrive with no referrer.
- Private sharing, sometimes called dark social. A visitor copies your link into a direct message, group chat, or email. The recipient's click has no social referrer, even though the first exposure was on social media.
- Redirects that strip information. If your site sends
http://visitors tohttps://, or a short domain to the main domain, the redirect can drop the query string. The referrer can also be lost. Always test that the final URL still carries the UTM parameters. - Switching browsers or devices. The visitor sees a post on their phone and later buys on a laptop. Without a login to join the two visits, the laptop session has no social trace.
- Typed or remembered visits. The visitor saw your brand on social media, then searched for you or typed your name. The social platform helped, but a later report credits search or direct.
The practical conclusion is that "direct" is partly hidden social. You cannot recover every case, but tagging every link you control keeps the share small.
The path of one click
The diagram shows where information is added or lost along a typical social click.
How GA4 interprets what arrives
GA4 sets a session's source and medium from the first usable signal, in roughly this order:
- Campaign parameters in the URL, such as
utm_sourceandutm_medium. - Click IDs it recognizes, mainly from Google Ads.
- The referrer, compared against a list of known sites such as search engines and social networks.
- Otherwise,
(direct) / (none).
Tagged links take priority over the referrer. This is why a tagged link from Instagram reports instagram / paid_social or whatever you wrote, even though the referrer says l.instagram.com. It is also why a typo in a tag can hide good social traffic. The next chapter covers naming conventions.
For untagged visits, GA4's default channel group treats a referrer from a known social site as Organic Social. A tagged visit lands in Paid Social only when its medium looks like a paid medium (for example cpc, paid_social, or paid) and its source is a recognized social site. Details are in the attribution chapter.
Checking a real visit
Do this before you trust any report:
- Pick one social platform you use.
- Post a link to a test page on your own site, in a private or low-visibility place such as a personal account or a direct message to yourself.
- Open the link from the phone app, then from the desktop site.
- Record the referrer host, whether the page opened in an in-app browser, and whether the query string survived.
- Compare your notes with how the visit appears in GA4's Realtime report. If you have not installed GA4 yet, use your server logs or the script above. Installation is the subject of a later chapter.
Repeat this for each platform and each link type, such as bio links, post links, story links, and ads. Bio links and ad links often behave differently from post links.
Common errors
- Assuming the referrer names the post. It names, at most, the platform's host.
- Reporting
l.facebook.comandfacebook.comas different channels. Group them under one source in your reports. - Testing only on desktop. Most social traffic is mobile and inside in-app browsers, where behavior differs.
- Forgetting redirects on your own site. A single
301that drops the query string breaks all campaign tagging for that URL. - Treating "direct" as "unknown and unimportant". Part of it is social and should lower your confidence in social's reported share, not be ignored.
Exercise
A visitor taps your Instagram bio link, reads your landing page in the Instagram in-app browser, and leaves. Two days later they type your domain into Chrome and buy. Your bio link has no UTM parameters. Name the referrer you expect on the first visit, how GA4 will probably classify each visit, and one reason the two visits are not joined.
Show answer
The first visit most likely carries a referrer of l.instagram.com (or none, depending on the app version), so GA4 usually reports it as an Instagram social or referral session. The second visit has no referrer and no tags, so it is classified as direct. The visits are not joined because the in-app browser and Chrome use separate cookies and storage, giving each visit a different client ID, and the visitor was not logged in to connect them.
Exercise
Your site redirects http://example.com/spring-sale?utm_source=instagram&utm_medium=paid_social to https://example.com/spring-sale. What goes wrong, and how do you check for it?
Show answer
The redirect drops the query string, so the UTM parameters never reach analytics and the visit loses its campaign attribution (and may look like direct or a bare referral). To check, click the tagged link in a browser and compare the final address bar URL with the original, or request it with a tool that shows redirect responses and look at the Location header. Fix the redirect rule so it preserves the query string.