Loyalty Links

Description

Loyalty Links is a WordPress plugin that implements a “give and take” approach to external linking. The plugin tracks which external domains have sent visitors to your site via referrers, and only allows links to those domains to remain functional. Links to domains that haven’t recently referred visitors are “broken” (href changed to “#”) while remaining visible on the page.

Key Features

  • Referrer Tracking: Automatically tracks external domains that send visitors to your site
  • Dynamic Link Breaking: Links to domains without recent referrers are automatically disabled
  • Selective Monitoring: Only monitor specific domains you choose – other external links remain untouched
  • Configurable Retention: Set how many days to retain referrer records (default: 30 days)
  • Test Mode: Add test domains to verify functionality without waiting for actual referrals
  • Cache-Friendly: Uses REST API endpoints for dynamic data, compatible with WP Rocket, WP Fastest Cache, and other caching plugins
  • Performance Optimized: Asynchronous script loading and efficient database operations

How It Works

  1. Track Referrers: When a visitor arrives from an external domain (in your monitored list), JavaScript sends the referrer information to a REST API endpoint which records the domain, timestamp, and increments the visit count
  2. Approve Domains: Domains that have sent referrers within your retention period are considered “approved”
  3. Break Links: Links pointing to non-approved domains have their href changed to # and pointer-events: none applied
  4. Real-Time Updates: Approved domains are fetched dynamically via REST API, ensuring cache compatibility

Use Cases

  • Encourage reciprocal linking by only allowing functional links to sites that link back to you
  • Create a “loyalty” system where sites that send traffic get link benefits
  • Test link management strategies without manual intervention
  • Maintain link quality by prioritizing domains that drive traffic

Installation

Automatic Installation

  1. Go to Plugins Add New in your WordPress admin
  2. Search for “Loyalty Links”
  3. Click “Install Now” and then “Activate”

Configuration

  1. Navigate to Settings Loyality Links
  2. Add domains to monitor (one per line) in the “Domain List” field
  3. Set “Retention Days” (how long to remember referrers)
  4. Optionally add test domains to verify functionality
  5. Click “Save Settings”

FAQ

How does the plugin track referrers?

The plugin uses JavaScript to read document.referrer on each page load and sends it to a REST API endpoint via AJAX. If the referrer is from an external domain in your monitored list, the endpoint records the domain, current timestamp, and increments the visit count.
This cache-friendly approach allows your HTML to be fully cached while tracking happens client-side.
The tracking request is sent asynchronously and doesn’t block page rendering, so it won’t slow down your page load times.

Will this work with caching plugins?

Yes! The plugin is designed to be cache-friendly. It uses REST API endpoints to fetch approved domains dynamically, so your HTML can be fully cached while link-breaking logic remains real-time.

What happens to links that are broken?

Broken links remain visible on the page but:
* Their href attribute is changed to #
* pointer-events: none is applied to prevent interaction
* CSS classes is-broken-link and loyalty-links-broken are added for styling
* The original href is stored in data-original-href attribute

Can I test the plugin without waiting for real referrers?

Yes! Use the “Test Domain” field in settings to add domains for testing. Test domains are never approved, so their links will always be broken regardless of retention settings.

Does the plugin affect internal links?

No. Internal links (same domain) are never modified. Only external links pointing to domains in your monitored list are processed.

What if I don’t add any monitored domains?

If your monitored domains list is empty, the plugin won’t track any referrers and won’t modify any links. It’s effectively disabled until you add domains to monitor.

How are domains normalized?

The plugin automatically removes the www. prefix and converts domains to lowercase for consistency. Both example.com and www.example.com are treated as the same domain.

Can I use this with other link management plugins?

The plugin only modifies links to domains in your monitored list. Other external links remain untouched, so it should be compatible with most other plugins. However, test thoroughly if using multiple link-related plugins.

What’s the performance impact?

Minimal. The plugin:
* Loads JavaScript asynchronously
* Uses REST API for dynamic data (doesn’t block page rendering)
* Tracks referrers client-side via JavaScript (cache-friendly)
* Runs cleanup on only 1% of requests to avoid performance impact

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Loyalty Links” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Loyalty Links” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.0.1

  • Added “Settings” link on the Plugins page (quick access to Loyalty Links settings)
  • Added “Documentation” link on the Plugins page (configuration guide on WordPress.org)

1.0.0

  • Initial release
  • JavaScript-based referrer tracking via REST API (cache-friendly)
  • Visit count tracking for monitored domains
  • Dynamic link breaking based on referrer history
  • Admin settings page with domain management and visit counts
  • Configurable retention period
  • Test domain functionality
  • REST API endpoints for cache-friendly operation (approved domains and referrer tracking)
  • Performance optimizations (async loading, efficient DB operations)
  • MutationObserver for dynamic content support