Guest Gate Theme Component

I have implemented an analytics tracking system for the Guest Gate v2.0 with full GTM (Google Tag Manager) support and flexible custom event logging.

Settings Added

  • enable_analytics (disabled by default): Toggles the entire tracking functionality on or off as requested.

  • analytics_debug_logging: When enabled, logs all tracked events directly to the browser console. This is especially helpful during setup when configuring GTM triggers.

Core Functionality

A dedicated helper module (guest-gate-analytics.js) handles event dispatching. Every tracked event is pushed to two destinations simultaneously:

  1. window.dataLayer.push(...): Automatically picked up by Google Tag Manager (GTM) and Google Analytics 4 (GA4) if active on the site.

  2. discourse-guest-gate:analytics (Custom Browser Event): Allows integration with third-party tools (e.g., Matomo, Plausible, or custom webhooks) without requiring any further code modifications.

Events Tracked

  • guest_gate_shown (Fired when the modal appears)

    • guest_gate_reason: The trigger type (page_view, time, scroll, or lightbox).

    • guest_gate_path: The URL path where the modal was shown.

  • guest_gate_click (Fired when the visitor interacts with the modal)

    • guest_gate_click_action: The specific action taken (login, signup, sso_login, sso_signup, external_<provider> such as Google login button, or dismiss if closed without taking action).

    • Includes the same reason and path metadata to easily correlate interactions with display triggers.

Privacy & Data Protection

  • No personally identifiable information (PII) is collected or transmitted, only the minimal operational metadata listed above.

Coming soon…:rocket:

> ./support --coffee

3 Likes