Skip to content

feat: WP Engine adaptation (permanent parallel branch)#1

Open
garrettatx wants to merge 2 commits intomainfrom
wp-engine
Open

feat: WP Engine adaptation (permanent parallel branch)#1
garrettatx wants to merge 2 commits intomainfrom
wp-engine

Conversation

@garrettatx
Copy link
Copy Markdown
Owner

Summary

  • Removes template_redirect hook and gd_ls_capture() PHP function — WP Engine's full-page cache prevents these from firing on cached pages
  • Moves all cookie capture logic to inline JavaScript (captureLeadSource()) that runs on every page load, cached or not
  • Ports referrer classification domain lists (search/social/AI) from PHP to JS — both stay in sync
  • Passes WordPress gmt_offset from PHP to JS so timestamps match WP admin time, not browser local time
  • Bumps version to 1.1.0-wpengine
  • Updates README with WP Engine-specific notes, testing steps, and known limitations

All cookie names, form field selectors, shortcodes, and attribution behavior (first-touch organic / last-touch paid) are identical between branches.

⚠️ Do Not Merge

wp-engine is a permanent parallel branch, not a feature branch. It serves a different hosting environment and should never be merged into main. This PR exists for code review only.

When main gets improvements that apply to both versions (e.g., new referrer domains, security fixes), cherry-pick or merge them into wp-engine selectively.

Test plan

  • Enable WP Engine page cache in staging
  • Visit with UTM params — verify gd_ls_* cookies are set via DevTools → Application → Cookies
  • Visit from Google organic — verify gd_ls_source=Google, gd_ls_medium=organic
  • Fill out a form — verify hidden fields contain correct cookie values
  • Submit a form — verify email notification shortcodes ([gd_ls_summary]) contain correct data
  • Verify timestamp matches WordPress site timezone, not browser local time

🤖 Generated with Claude Code

Garrett Digital added 2 commits March 5, 2026 13:18
WP Engine's aggressive full-page cache prevents PHP hooks like
template_redirect from firing on cached pages. This branch removes
the server-side gd_ls_capture() function and template_redirect hook,
replacing them with a JS-based capture function in gd_ls_inline_script().

The JS handles:
- Parsing window.location.search for UTM params and gclid
- Reading document.referrer for referrer classification
- Referrer domain lists (search/social/AI) ported from PHP to JS
- Cookie writes via document.cookie with same gd_ls_ prefix and 30-day expiration
- Same first-touch / last-touch attribution rules as the PHP version
- Landing page captured from window.location.href

All PHP shortcodes, Formidable Forms, Contact Form 7, and Gravity Forms
integrations are unchanged. Cookie names, form field selectors, and
attribution behavior are identical between branches.

Version bumped to 1.1.0-wpengine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant