Setup & site building · Guide
How to Track Affiliate Links in WordPress (Step by Step)

Short answer
Use a link management plugin such as Pretty Links or ThirstyAffiliates to count clicks on each affiliate link. Send those clicks to GA4 as events to see which pages drive them. Then add sub-IDs or tracking IDs so your affiliate network shows which page earned each sale.
Key takeaways
- Clicks, source pages and sales live in different tools.
- Link plugins count clicks through short redirect links.
- GA4 may miss cloaked links unless you add a custom event.
- Sub-IDs connect network sales to specific pages.
- Mark affiliate links with rel sponsored.
- Disclose affiliate relationships clearly to readers.
How do you track affiliate links in WordPress?
Use a link management plugin to count clicks on each affiliate link, add GA4 event tracking to see which pages send those clicks, and use your affiliate network's sub-IDs to match clicks to sales.
Tracking affiliate links answers three different questions. How many people clicked, where they clicked from, and which clicks turned into commission.
No single tool answers all three. Your WordPress site sees the click, while the affiliate network sees the sale.
This guide shows how to set up each layer, how they fit together, and the common mistakes that make numbers look wrong.
What should you track for affiliate links?
Track clicks per link, clicks per page, and conversions per page or campaign, because together they show which content actually earns money.
Here is what each layer tells you and where the data lives:
| What you want to know | Where to measure it |
|---|---|
| How often each affiliate link is clicked | Link management plugin |
| Which posts and pages send the clicks | GA4 events or the plugin's referrer data |
| Which clicks became sales | Affiliate network or merchant dashboard |
| Which page earned each sale | Sub-IDs or tracking IDs in the affiliate link |
| Revenue per visitor for a post | GA4 traffic plus network earnings |
Clicks alone can mislead. A post with many clicks but few sales may be sending visitors to a poor offer.
If you are just starting, our guide on how to start affiliate marketing with WordPress covers the basics before tracking.
Step 1: How do you set up a link management plugin?
Install a plugin such as Pretty Links or ThirstyAffiliates, add each affiliate URL as a short link on your domain, and use those short links in your content so every click is counted.
These plugins create links such as yourdomain.com/go/product that redirect to the long affiliate URL. Each redirect is logged as a click.
The basic setup looks the same in most tools:
- Install the plugin from Plugins, then Add New.
- Create a new link and paste the full affiliate URL as the target.
- Choose a short slug, such as go/product-name.
- Pick a redirect type. A 307 or 302 temporary redirect is common for affiliate links.
- Turn on the nofollow and sponsored options.
- Insert the short link into your posts instead of the raw affiliate URL.
Pretty Links and ThirstyAffiliates are both listed in the WordPress plugin directory. Their free versions count clicks, and paid versions add more reporting, so check each vendor page for current features.
A central link list has a second benefit. When a program changes its URL, you update one link instead of editing every post.
For more on the redirect side, see our guide on how to cloak affiliate links in WordPress.
Step 2: How do you view click reports in the plugin?
Open the plugin's links or reports screen in the dashboard, where each link shows its total clicks and, in many plugins, unique clicks, dates and referring pages.
Use the reports to spot patterns:
- Links with many clicks show strong reader interest.
- Links with zero clicks may be placed badly or point to an offer nobody wants.
- A sudden drop can mean a broken link or a page that lost search traffic.
Many plugins let you exclude bots and your own visits from counts. Turn this on so testing does not inflate the numbers.
Click logs can grow large on busy sites. Check the plugin's settings for options to trim old click data so your database stays lean.
Step 3: How do you track affiliate clicks in Google Analytics 4?
Turn on enhanced measurement for outbound clicks in GA4 for direct affiliate links, and use Google Tag Manager or a plugin event for cloaked links that start with your own domain.
GA4 can record clicks on links that lead to another domain. Google describes this in its enhanced measurement events help page. The event is called click, and it includes the link URL and domain.
There is a catch. A cloaked link such as yourdomain.com/go/product points to your own domain first, so GA4 may not treat it as an outbound click.
You have three ways to handle this:
- Google Tag Manager: create a click trigger for link URLs containing /go/ and send a custom GA4 event, such as affiliate_click.
- Plugin integration: some link and analytics plugins can send affiliate clicks to GA4 as events for you.
- Direct links: use the raw affiliate URL so enhanced measurement catches it, and rely on GA4 instead of the link plugin.
Our guide on how to add Google Tag Manager to WordPress shows how to install the container.
Once events arrive, build a GA4 exploration with the page path and the link URL. You then see exactly which posts send the most affiliate clicks.
Step 4: How do you track which page made a sale?
Add a sub-ID or tracking ID to each affiliate link that names the page or placement, then read sales by that ID in your affiliate network's reports.
Your site cannot see purchases on the merchant's site. The network can, and sub-IDs carry your page names across to its reports.
Most networks support some form of sub-ID, sometimes called a SID, click reference or custom parameter. The parameter name differs by network, so check its help pages.
A simple naming system helps:
- best-cameras-table for a comparison table link.
- best-cameras-cta for a button at the end of the same post.
- newsletter-june for an email link.
Amazon Associates works a little differently. Instead of sub-IDs, it uses separate tracking IDs that you create in your Associates account and add to links.
Keep a spreadsheet of every ID and where it is used. Without it, reports full of codes become hard to read months later.
How do you put the click and sales numbers together?
Compare clicks per page from your plugin or GA4 with sales per sub-ID from your networks, then work out earnings per click and earnings per visitor for each post.
Two simple numbers make decisions easier:
- Earnings per click: commission for a link or page divided by its clicks.
- Earnings per visitor: commission for a post divided by the post's sessions in GA4.
A post with modest traffic but high earnings per visitor deserves updates and internal links. A post with high traffic and low earnings needs better offers or placements.
Review these numbers monthly rather than daily. Affiliate data is often delayed, and returns or cancelled orders can change totals.
Our guide on how to measure blog traffic in WordPress explains the GA4 traffic side.
How should affiliate links be marked for search engines?
Add the rel="sponsored" attribute to affiliate links, and nofollow if you like, so search engines know the links are paid placements and do not pass ranking credit.
Google asks site owners to qualify paid links this way. Its guide to qualifying outbound links explains the sponsored and nofollow values.
Link management plugins can add these attributes automatically to every affiliate link. That is safer than remembering to add them by hand.
Marking links does not affect click tracking. The redirect and the analytics event still work the same way.
Do you need to disclose affiliate links you track?
Yes, in many places you must clearly tell readers that you earn a commission, and tracking with cookies or analytics may also need a privacy notice or consent.
This is general information, not legal advice. Rules differ by country, so check the guidance that applies to you.
In the United States, the FTC's endorsement guidance explains that affiliate relationships should be disclosed clearly and near the link.
Tracking also involves visitor data. Click logs that store IP addresses and analytics cookies may need to be covered in your privacy policy, and in some regions behind cookie consent.
Our guide on how to add affiliate disclosures in WordPress shows practical ways to place them.
Why do affiliate click counts not match network reports?
Counts rarely match because plugins, GA4 and networks filter bots, duplicate clicks and blocked scripts differently, and networks may only count clicks that reach the merchant.
Small gaps are normal. Large gaps usually point to a setup problem.
Check these common causes:
- Ad blockers stop GA4 from recording some clicks, but the plugin redirect still counts them.
- Bot traffic may be counted by a plugin but filtered by the network.
- Caching can serve old pages with outdated links.
- Broken redirects send visitors to an error page before the network sees them.
- Expired tracking IDs or wrong sub-ID parameters drop the attribution.
Test each important link from a private browser window after publishing. Then check that the click appears in the plugin and, a while later, in the network dashboard.
Regularly scanning for broken links also protects earnings. See our guide on how to find broken links in WordPress.
Frequently asked questions
What is the best free way to track affiliate link clicks in WordPress?
A free link management plugin is the simplest start. Pretty Links and ThirstyAffiliates both have free versions that count clicks on short redirect links. Pair that with GA4 for page-level data, and use your affiliate network reports for sales.
Does Google Analytics track affiliate link clicks automatically?
Partly. GA4 enhanced measurement records clicks on links to other domains as outbound clicks. Cloaked links that start with your own domain may not count as outbound, so set up a custom event with Google Tag Manager or a plugin integration for those.
Can I see which blog post made an affiliate sale?
Yes, if you add a sub-ID or tracking ID to each link that names the post or placement. Your affiliate network then reports sales by that ID. Without it, you can see clicks per post but not which post produced the sale.
Do cloaked affiliate links break tracking?
No, when set up correctly. The plugin redirects to the full affiliate URL, which still carries your affiliate ID, so the network credits the sale. Test each link after creating it to confirm it lands on the right page with your ID intact.
Should affiliate links be nofollow or sponsored?
Google asks for paid links, including affiliate links, to be marked with rel sponsored, and nofollow is also accepted. Most link plugins can add these attributes automatically. The attribute does not stop click tracking from working.
Sources
- Enhanced measurement events Google Analytics Help
- Qualify your outbound links to Google Google Search Central
- Pretty Links WordPress.org Plugins
- ThirstyAffiliates WordPress.org Plugins
- FTC's Endorsement Guides: What People Are Asking Federal Trade Commission
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


