Well according to Chat (again) this is a known issue: plugins like WooRewards don’t run on the first visit via a referral URL — the plugin’s code doesn’t execute until a second visit, which suggests something is bypassing WordPress early on.
From reddit: “It usually comes down to caching and when WooCommerce sessions actually start. What helped me was hooking into WordPress really early, like on init or wp_loaded, to catch the referral info before any caching or redirects happen."
Immediate Fixes to Try
1. Ensure Cloudflare Excludes Referral URLs from Cache
Cloudflare’s default behavior often serves cached pages for URLs with query parameters unless explicitly configured otherwise. You can address this by:
• Using Cache Rules to bypass caching when the query string contains your referral parameter. Example rule: (If http.request.uri.query contains "ref", then bypass cache.)
2. Use Cloudflare Transform Rules for Query Ignoring
If you’re using “Cache Everything,” query strings may still get cached. Transform Rules can help you ignore specific query parameters — like ref — to ensure each visit is treated as unique
3. Launch Referral Logic at the Earliest Hooks
Move your referral tracking code to the earliest stages of WordPress execution — ideally in an mu‑plugin — using hooks like:
add_action('init', 'set_referral_cookie', 1);
function set_referral_cookie(){
if (isset($_GET['ref'])) {
setcookie('custom_ref', sanitize_text_field($_GET['ref']), time() + DAY_IN_SECONDS * 30, '/');
error_log('Referral cookie set: ' . $_GET['ref']);
}
}
If you don’t see this log on first visit — but do on reload — it’s strong evidence that the code isn’t being run due to caching interference.
4. Add Debug Logs for Plugin Calls
Add logging at the very start of your referral plugin’s main file or in a mu-plugin:
error_log('Referral plugin reached init at ' . current_time('mysql'));
If you don’t see this log on first visit — but do on reload — it’s strong evidence that the code isn’t being run due to caching interference.
Summary Diagnostic Flow
Step
Description
1. Add early logging
Confirm if plugin or cookie logic executes at first visit.
2. Test referral link
Use curl -I https://satosh.ee/?ref=test — check headers like cf-cache-status: HIT vs MISS.
3. Adjust cache rules
Use Cloudflare Cache or Transform rules to bypass referrals.
4. Validate in Incognito
Remove preload/prefetch interference from browser.
5. Re-test every change
Confirm if the plugin logic actually runs on first visit post-changes.