Cloaked links and geo-routing
OAmazon manages your affiliate links instead of inserting raw amazon.com/dp/<ASIN>?tag=<id> URLs in your posts. Every link is a cloaked /go/<slug>/ URL that redirects with the correct associate tag for the visitor's locale.
Why cloaked links
- One URL works for any locale (geo routing applies the right marketplace per visitor).
- Edit destination, UTM, or expiry without touching post content.
- Track clicks with hashed IP/UA, country, device type.
- Schedule start/end dates per link.
- Run A/B tests between displays without re-publishing posts.
Creating a link
php$link = OAM_Links::get_or_create( 'B08N5WRWNW', 'us' );
$url = OAM_Links::get_cloaked_url( $link['slug'] );
// returns https://yoursite.com/go/<slug>/Manual creation under Links tab -> New Link lets you set:
- Custom slug and label.
- Locale (
autofor geo-routed, or pinned to one region). - UTM source/medium/campaign.
- Start/End dates.
- Redirect status (default 302).
Geo routing
OAM_Geo::get_visitor_locale() resolves the visitor's locale from (in priority order):
- The
OAM_VISITOR_COUNTRYconstant (if defined by a geo-IP plugin). - Cloudflare's
CF-IPCountryheader. - WP option
oam_visitor_locale(per-session). - Browser's
Accept-Languageheader. - The configured Default Locale in Settings.
When geo routing is enabled (link has geo_enabled = 1) and the visitor's resolved locale differs from the link's pinned locale, the redirect uses the visitor's local Amazon storefront with the matching Associates ID from oam_programs.
PA API endpoint map
OAM_API::ENDPOINTS covers 18 locales: us, uk, ca, de, fr, it, es, jp, au, in, br, mx, sg, ae, nl, se, tr, pl. Each maps to a host (e.g. webservices.amazon.de), AWS region, and TLD.
Health checks
OAM_Cron::schedule_all() registers a daily health check that verifies each managed link still resolves (no 404, no out of stock). Status is stored in oam_links.health_status and surfaced in the admin.

