UTM tracking and customer source: how to know where a buyer came from, even if they bought a week later
Someone clicks your ad and buys a week later after typing in your address. How UTM tags and a first-touch record keep the source attached to every single order.
6 min read

In this article
On Monday someone clicks your Facebook ad, looks around your site and leaves. The following Monday they type in your address and buy. If you only see the last visit, that sale looks like "direct" — and the ad that brought it looks like wasted money. This article explains how UTM tags and a simple source record on every order preserve the answer to "where did this buyer come from".
We write from practice: we recently set up this kind of source tracking for a client's website with an order system.
What UTM tags are and how to write them
UTM tags are parameters at the end of a link that say where a visitor came from. The page opens exactly the same, but analytics and your own system can read the tags and store them. For example:
https://example.com/?utm_source=facebook&utm_medium=paid&utm_campaign=autumn
utm_source— the source: facebook, google, ig, newsletter;utm_medium— the channel type: paid, social, email;utm_campaign— the campaign, so you can compare two ads with each other.
Three rules that save hours of report clean-up later:
- Lowercase only.
Facebook,facebookandFBbecome three different sources in a report. - Consistent names. Agree once (for example, Instagram is always
ig, never sometimesinstagram) and keep the list in a sheet that everyone who creates links can see. - UTM tags are for external links only. Never put them on links inside your own site — the menu, a banner, a homepage button. A tagged internal link overwrites the real source: a visitor who came from an ad turns into "banner" in your report.
The smallest step with a tangible payoff is your Instagram profile link. We added ?utm_source=ig&utm_medium=social to the link in the bio and saw a real order that came from exactly there. Without the tag, we would never have known its source.
When there is no tag: fbclid, gclid and the referrer
Not every link will be tagged: people share links, and ads sometimes go live in a hurry. So we determine the source in this order:
- The link has UTM tags — use them.
- It has
fbclid— record "facebook / paid". - It has
gclid,gbraidorwbraid(Google Ads click identifiers) — "google / paid". - Otherwise — the referring site's domain: a search engine, a portal, a partner's website.
- If there is none — "direct".
One caveat: Facebook adds fbclid not only to ads but to some ordinary links as well, so "facebook / paid" without UTM tags is an approximation. Tag your ad links with your own UTMs anyway — they are more precise and take priority over automatic detection.
First touch and last touch
This is where the "clicked an ad, bought a week later" question gets its answer. We store the source in two ways:
- First touch — the source of the first visit. It is saved in the browser's
localStoragefor 90 days, and later visits do not overwrite it. - Last touch — the source of the current visit (session). It changes every time the person arrives from a different source.
When an order is created, both are saved with it. In the Monday example you would see first touch "facebook / paid" and last touch "direct". Both are correct; they simply answer different questions. The first shows what brought the customer in, the last shows what brought them back to buy.
Know the limits up front. The source lives in one browser: if someone saw the ad on their phone and bought on a laptop, there is no link between the two. Ninety days is the window we chose; if your customers take longer to decide, you can extend it.
Where to store the source: next to the order, not instead of the order system
The most important decision is what not to store. Your order system (online store, booking plugin, accounting software) already knows who bought what, when and for how much. That data must live in one place: a second copy will sooner or later drift away from the first, and you will no longer know which one to trust.
So we only collect what the order system does not have — the source. It has to be captured, because it disappears for good: once the tab is closed, there is no way to reconstruct it. The record is simple: order number; first-touch source, channel and campaign; the same for last touch; and a date. In reports, the source is joined to orders by order number.
The same principle works for enquiries: the source can travel with every contact form message. We covered automating the form itself in Website lead form automation.
Privacy and clean data
- No personal identifiers. The source record holds no name, email or phone number — only source, channel, campaign and order number. Personal data stays in the order system.
- Bots are skipped. Browsers driven by automation tools announce themselves (
navigator.webdriver); we do not record those visits, so tests and bots do not skew the numbers. - Rate limiting. The endpoint that receives source records limits the number of requests, so nobody can flood it with junk.
- A clear retention period. We keep source records for 3 years — enough to compare the same season across different years.
If your site asks for cookie consent, make sure the browser-side source record respects it too. This is technical, not legal advice; check the rules that apply to you.
A report that opens properly in Excel
We export source data as a CSV file. Two small details decide whether it is usable:
- A semicolon (
;) as the separator. Excel with Lithuanian regional settings, like many other European ones, opens a comma-separated file as a single column. - A BOM at the start of the file. Without it, Excel may not recognise UTF-8, and Lithuanian letters such as "ą", "č" and "š" turn into gibberish.
Once the file is open, build a pivot table by first-touch source: how many orders and how much revenue each channel brought. Then do the same by last touch. The difference between the two shows which channels bring in new people and which only bring back people who already know you.
If you would like us to set up this kind of source tracking for your website or system, see our web systems page.
What to do tomorrow
- Create a sheet of UTM names (sources, channels, campaigns) in lowercase and stick to it.
- Add UTM tags to your Instagram profile link and to every ad link.
- Check that none of your site's internal links carry UTM tags — if any do, remove them.
Frequently asked questions
Does the source record replace Google Analytics?
No, it complements it. Analytics shows aggregated traffic, while a source record on an order answers for a specific sale: this order came from this ad. The numbers may differ slightly, because they are counted differently.
Why not write the source straight into the order system?
If your system lets you add custom fields, you can. The principle stays the same: do not duplicate order data — add only what is missing, which is the source.
Should newsletter links be tagged?
Yes: utm_source=newsletter&utm_medium=email, with the campaign set to the email's subject or date. Some clicks from email apps arrive without a referrer and, untagged, would look like "direct".