How to display tracked affiliate information in WordPress
To display tracked affiliate information, your site needs an affiliate system such as AffiliateWP to identify the referring visitor. You can build a custom shortcode that reads the tracked affiliate and its WordPress profile, or use AffiliateWP Affiliate Info to add ready-made shortcodes for names, websites and other details.
- 01Confirm affiliate tracking works
- 02Choose safe information to display
- 03Build the manual shortcode route
- 04Install AffiliateWP Affiliate Info
- 05Add the display shortcodes
- 06Test tracking and caching
What you need
- AffiliateWP installed and tracking referral links
- Administrator or developer access to WordPress
- A page, template or widget area where the information should appear
- A test affiliate referral URL
Confirm affiliate tracking works
Before displaying anything, confirm that AffiliateWP is active and that affiliates have working referral URLs. A visitor must first arrive through a referral URL so the tracked affiliate can be identified.
AffiliateWP stores the referring affiliate in browser cookies, including affwp_ref. If the cookie is missing, the page has no affiliate information to show.
Choose safe information to display
Decide whether visitors should see the affiliate’s display name, website, biography, username, image or contact details. The display name is usually the safest choice for a message such as “You were referred by [name]”.
Be careful with email addresses and personal profile data. Only show contact details when the affiliate has agreed to that use, and provide fallback content for visitors who did not arrive through an affiliate link.
Build the manual shortcode route
If you already have AffiliateWP and want to avoid an additional addon, a developer can create a small shortcode in a child theme or code-snippets plugin. It should ask AffiliateWP for the currently tracked affiliate, retrieve the connected WordPress user’s approved profile data, escape the output, and return nothing or fallback text when no affiliate is tracked.
Use AffiliateWP’s documented PHP functions for Affiliate Info rather than reading the tracking cookie directly. This route gives you full control over the HTML, but it requires PHP maintenance and can break when a theme is edited, AffiliateWP changes its API, or page caching serves one visitor’s output to another.
Install AffiliateWP Affiliate Info
For the faster route, install and activate the AffiliateWP Affiliate Info addon after AffiliateWP is active and its licence is verified. The addon adds shortcodes that read the affiliate currently being tracked and can be used in posts, pages and widget areas.
This is the practical choice when you need a visible referral message without maintaining custom PHP. It is designed specifically for showing tracked affiliate profile information on the front end.
Add the display shortcodes
Place the relevant shortcode in a Shortcode block, widget, page-builder shortcode element or supported content field. For example, use [affiliate_info_name] for the tracked affiliate’s WordPress display name, or combine it with a message.
To show content only when tracking exists, wrap the message in [affiliate_info_referred] and [/affiliate_info_referred]. Use [affiliate_info_not_referred] for a fallback shown when no affiliate is being tracked. Other available fields include the website, username, biography, Gravatar and email address.
Test tracking and caching
Open a private browser window, click a real affiliate referral URL, and visit the page containing the message. Check that the expected name appears, then repeat the test without a referral URL to confirm the fallback behaves correctly. Clear cookies between tests because an earlier referral can remain active.
If the output is blank or the wrong affiliate appears, check the affwp_ref cookie, purge page caches and exclude AffiliateWP tracking cookies from caching. A full-page cache can otherwise serve one visitor’s affiliate message to everyone.
Let AffiliateWP Affiliate Info do it
Displays the tracked affiliate’s name and details on the front end, ideal when referral transparency matters more than reporting.
Sources
- affiliatewp.com /docs/how-does-affiliatewp-track-visits-with-cookies/?utm_so…
- affiliatewp.com /addons/affiliate-info/
- affiliatewp.com /docs/affiliate-info-installation-and-usage/
Questions
- Can WordPress display the referring affiliate without a plugin?
- WordPress cannot identify an AffiliateWP referral by itself, so you need AffiliateWP or another affiliate-tracking system first. Once tracking exists, a developer can create a custom shortcode that retrieves the tracked affiliate and prints selected profile data. Without that custom code or an addon, WordPress has no built-in field for the current referring affiliate.
- Which shortcode displays the tracked affiliate’s name?
- Use <code>[affiliate_info_name]</code> to display the tracked affiliate’s WordPress display name. Put it in a page, post, widget or supported page-builder field. To prevent empty labels appearing for ordinary visitors, place it inside <code>[affiliate_info_referred]</code> and <code>[/affiliate_info_referred]</code>.
- Why is the affiliate information blank?
- The information is usually blank because the visitor has not arrived through a tracked referral URL, the tracking cookie was cleared, or caching has removed or hidden the affiliate context. Test in a private window, confirm the <code>affwp_ref</code> cookie exists, purge caches and exclude AffiliateWP cookies from page caching.
- Can I show the affiliate’s email address publicly?
- Yes, the Affiliate Info addon provides an email shortcode, but public email display needs careful privacy handling. Get the affiliate’s permission first, consider spam exposure, and avoid showing the address unless visitors genuinely need it. A name, website or approved contact form is usually safer.
- Does the displayed affiliate change when another referral link is clicked?
- It can change when AffiliateWP is configured to credit the last referrer. The displayed information follows the affiliate that AffiliateWP currently has tracked for that visitor, subject to the site’s referral and cookie settings. Test this behaviour with separate browser sessions before relying on it for personalised landing pages.