How to Redirect Affiliate Links by Device in WordPress
One link, two destinations, decided by the visitor's device. Here is how to set that up in WordPress, which redirect type to use, and how to stay on the right side of Google.
On this page
Redirecting affiliate links by device works the same way in WordPress whatever the offer: you publish one link on your site and let a rule pick the destination, so a phone can go to an app listing or a mobile-specific offer while a laptop goes to the standard product page. WordPress has no device targeting built in, so this needs a rule based redirect plugin, and the whole job takes about five minutes per link once you know the order to do it in.
The important decision comes before any of that. Device redirects are worth it only when the destination genuinely changes with the device, and most of the time it does not.
When Device Targeting Is Actually Worth It
Good cases share one trait: a phone buyer and a desktop buyer would end up somewhere different even if you routed them by hand. An app store listing for mobile against a browser-based signup for desktop. A platform-specific download. A merchant landing page that only works properly on a small screen. A software deal where the mobile version is a separate product.
Bad cases are the ones where the page just needs to look different, and responsive design already handles those on a single URL. If you are considering a device rule mainly because your page renders awkwardly on phones, fix the page. We drew that line in more detail in when mobile and desktop visitors need different pages.
How a Device Rule Decides
A device rule reads the user agent, the short line every browser sends to identify itself, and sorts the request into desktop, mobile or tablet. This happens on the server before anything renders, so the visitor lands directly on the right destination with no flicker and no client-side script that an ad blocker could strip out.
Detection is good, not perfect. MDN is blunt that browsers have been reducing the detail in user agent strings for privacy reasons, so treat classification as a strong signal rather than a guarantee. Every rule needs a default destination for the clients it cannot classify, including crawlers, feed readers and anything unusual, and that default should be the link that is safe for everybody.
Setting Up the Rule Step by Step
Start by giving the offer one address on your own site, something like /go/product-name, and use that everywhere instead of pasting the merchant URL into posts. That single change makes the destination editable in one place later.
Then build the rule. Set the default destination first, which is usually your desktop or standard merchant link. Add a device condition for mobile pointing at the app listing or mobile offer, and add a separate tablet condition only if a tablet genuinely needs its own destination, since most of the time a tablet should follow the desktop path. Save the rule, then purge your cache so no stale copy of the old redirect is still being served.
DevDome Redirect Manager handles the whole set: include or exclude desktop, mobile and tablet per rule, choose the status code per rule, and auto-purge 10 cache plugins so a cached response never sends a phone user to the desktop destination.
Pick the Right Redirect Type
Affiliate rules should almost always be temporary redirects. The destination changes whenever the offer expires, the merchant reorganises, or you swap products, and a temporary redirect tells search engines the original address is staying put. A permanent redirect announces that the old URL is gone for good, which is the wrong signal for a link you will edit next quarter.
If you are unsure which code your existing links return, run one through a free redirect checker and read the status line. The full breakdown of when each type applies is in 301 vs 302 redirects.
Stay on the Right Side of Google
There is one real risk with device targeting, and it is cloaking: showing search engine crawlers a different destination from the one real visitors get. Google treats deliberately different treatment for crawlers as a spam policy violation, and the penalty is not worth the trick.
Staying clean is simple. Do not write conditions that single out crawler user agents, let them fall through to your default like any other unclassified client, and keep the logic the same for a real phone and a mobile crawler. Device routing done for the visitor’s benefit is a normal, honest technique.
Test From Real Devices, Not a Narrow Window
A narrowed desktop browser window is still a desktop request as far as the rule is concerned, so resizing proves nothing. Test from an actual phone, on mobile data, in a private window, and confirm you land where the rule says you should. Then repeat on a laptop.
If the click does not show up where you expect afterwards, separate the two possible faults: the redirect itself, which the redirect checker will confirm, and your measurement, which is a different problem entirely. That second one has its own checklist in what to do when GA4 realtime is not showing visitors.
Read the Click Data Per Device
Once rules are live, the click counts per rule tell you whether the split was worth building. If mobile and desktop convert the same way through one destination, retire the rule and keep your setup simple. Device targeting earns its place only when the numbers show two audiences behaving differently.
Just make sure those numbers are people. On one of our own affiliate sites last month, humans made about 9,450 tracked clicks while bots fired another 4,070, so roughly 3 in 10 raw click events were automated, and a browser-side counter would have folded every one of them into the totals. Server-side counting keeps them out. The same logic applies if you are routing by location rather than hardware, which we covered in how to redirect visitors by country.
Disclosure: DevDome publishes this blog and makes the products it mentions. We describe what they do rather than promise results.
Key takeaways
- Only redirect by device when the destination genuinely differs, such as an app listing versus a web page.
- Use one cloaked link on your site and let a rule pick the destination per device.
- Set a default destination that is safe for every device, because unknown clients fall through to it.
- Use a temporary redirect for offers you will change, and keep the rule cache-safe.
- Never serve search engines a different destination from real users, which is cloaking.
Sources
- MDN: the User-Agent request header — what the browser actually sends, and why user agent sniffing has limits
- Google Search Central: spam policies — why showing crawlers something different from users counts as cloaking
Links last checked August 12, 2026.
Frequently asked questions
Does redirecting affiliate links by device hurt SEO?
Not on its own. Affiliate destinations are usually external pages you do not want indexed anyway, and routing a real phone user to a phone-appropriate offer is legitimate. The line you must not cross is cloaking, meaning showing search engine crawlers a different destination from the one real visitors get. Treat crawlers exactly like any other unknown client and send them to your default.
How does the plugin know which device someone is using?
It reads the user agent, the short identification line every browser sends with a request, and classifies it as desktop, mobile or tablet. Detection happens on the server before the page loads, so there is no flicker and no script for a blocker to strip. Anything it cannot classify falls through to the rule's default destination.
Should I send mobile visitors to a merchant's app instead of the site?
Only if the app link genuinely converts better for your audience, and only after checking your affiliate program's terms on app links and tracking. Some programs do not credit in-app purchases the same way, so test with a small rule before moving all your mobile traffic.
301 or 302 for an affiliate link?
A temporary redirect fits most affiliate rules, because the destination changes whenever the offer, the merchant or the product does. Reserve a permanent redirect for moves you never intend to reverse, since it tells search engines the old address is gone for good.