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

Guest Gate v2.0 - A major update

After quite a bit of work, I’m happy to release Guest Gate v2.0. :tada:

Guest Gate started as a relatively simple theme component based on the original Guest Gate Sign Up Popup plugin, allowing anonymous visitors to be encouraged or required to Sign Up or Log In after viewing a certain number of topics.

Over time, the component grew considerably, and the original implementation became increasingly difficult to extend.

So v2.0 is not just a refactor or visual update. It introduces a completely new trigger system, better customization, optional analytics, and a number of improvements under the hood.

What’s new in v2.0?

Multiple trigger types

Guest Gate is no longer limited to topic/page views.

You can now trigger the gate based on:

  • Page views

  • Time

  • Scroll depth

  • Lightbox/image opening

  • Any - trigger the gate when the first configured trigger condition is met

Each trigger has its own configurable threshold.

You can also configure a delay between the trigger and the modal appearing.

This makes it possible to create different types of gates, for example:

Show the gate after 3 page views.

or:

Show the gate after 60 seconds.

or:

Show the gate when the visitor has scrolled through 70% of the page.

Repeat behaviour

The old random page-view behaviour has been expanded into a proper repeat system.

You can choose between:

  • Repeat trigger: show the gate whenever the configured trigger fires.

  • Random page views: show the gate after a random number of page views.

  • Once per session: show the gate at most once during the browser session.

The existing “show only once” behaviour is also preserved for backwards compatibility.

Better modal customization

v2.0 adds more control over the modal itself.

You can now configure:

  • Modal size: compact, standard or wide

  • Body alignment

  • Footer alignment

  • Title visibility

  • Title positioning

  • Login button style and icon

  • Signup button style and icon

The custom gate has also been improved with better control over:

  • Image alignment

  • Image width

  • Image alternative text

  • Heading alignment and colour

  • Text alignment and colour

  • Background colour

  • Footer and link colours

The custom image is now optional and also uses lazy loading and decoding hints.

Analytics

Guest Gate v2.0 includes optional privacy-conscious analytics.

When enabled, Guest Gate tracks:

  • Gate impressions

  • Trigger reason

  • Page path

  • Login clicks

  • Sign Up clicks

  • SSO actions

  • Dismiss actions

Events are exposed through window.dataLayer and are also dispatched as the browser event:

discourse-guest-gate:analytics

This allows Guest Gate to be integrated with analytics and tag-management platforms such as Google Analytics, Google Tag Manager, Matomo, or custom analytics implementations.

No personal data is collected by Guest Gate.

Analytics are disabled by default.

Existing installations

One of the important parts of v2.0 is that existing configurations don’t have to be recreated manually.

A settings migration has been added to migrate the old Guest Gate settings to their v2 equivalents.

This includes settings such as:

  • max_guest_topic_views

  • dismissable_false

  • gate_show_when_thumbnail_clicked

Existing configurations should therefore continue to work after upgrading.

The component now officially requires Discourse 3.2.0 or newer.

Why v2.0?

The original Guest Gate was primarily designed around limiting how many topics anonymous visitors could view.

The goal of v2.0 is to make it much more flexible.

Guest Gate can now be used as a general visitor conversion and engagement gate, while still supporting the original use case.

For example, you can use it to encourage registration after a visitor has:

  • Read several topics

  • Spent a certain amount of time on the site

  • Scrolled through an article

  • Opened an image

  • Reached any combination of configured conditions


This was a fairly substantial rewrite, so I’m sure there may still be things that can be improved.

Thank you to everyone who has used, tested and provided feedback on Guest Gate over the years. :heart:

I’ve updated the OP too.

Guest Gate v2.0 is now available. :rocket:

> ./support --coffee :heart:

4 Likes