CR Bee Docs

GA4 Tracking

Push GA4 e-commerce events to your site's window.dataLayer

CR Bee Connect can push standard GA4 e-commerce events to your site's window.dataLayer so your existing Google Tag Manager, GA4 plugin, or Site Kit setup forwards them to GA4. The plugin does not load Google Tag Manager or gtag.js itself — it only emits events for your existing analytics setup to pick up.

If your site doesn't have GA4 / GTM yet, install one of those first. CR Bee Connect just produces the events — something else has to forward them.

Events emitted

EventWhen
view_item_listResults page renders
view_itemVehicle details page renders
add_to_cartCustomer ticks an addon checkbox, increments quantity, or selects an insurance tier
begin_checkoutCheckout page renders
purchaseConfirmation page renders (deduplicated)
checkout_contactCustomer taps the WhatsApp or phone request option on checkout — a high-intent handoff that leaves the funnel instead of submitting (the email channel already fires purchase)

Payloads follow GA4's standard e-commerce schema. Each event includes currency, value, and an items[] array with item_id, item_name, item_category, price, quantity. Vehicles also include item_brand (make) and item_variant (rental duration like "5 days").

checkout_contact is the exception: it carries currency, value (the live cart total, coupon-adjusted), and a top-level contact_method (whatsapp or phone) — no items[]. Use it as a secondary conversion for booking intent that contacts you instead of completing online.

Enabling tracking

  1. Go to Settings → CR Bee Connect → Tracking.
  2. Check Enable GA4 event tracking.
  3. Choose a consent mode (see below).
  4. Save.

Default state: off. Existing installs upgrade with no behavior change.

Verifying events reach dataLayer

Open any booking page with browser DevTools open and run in the Console:

dataLayer.filter(e => ['view_item_list','view_item','add_to_cart','begin_checkout','purchase','checkout_contact'].includes(e.event))

If your page has tracking enabled and you've walked the relevant flow, you'll see one or more event objects with full payloads. Events in dataLayer confirm the plugin is working. If they're not appearing in GA4 itself, the issue is in your GTM/GA4 setup — see the next section.

Connecting events to GA4 via Google Tag Manager

The plugin pushes to dataLayer, but GTM does not automatically forward dataLayer pushes to GA4. You need a GA4 Configuration tag plus an Event tag with a Custom Event trigger.

Step 1 — GA4 Configuration tag

Open https://tagmanager.google.com → your container → TagsNew:

  • Tag type: Google Tag (formerly "GA4 Configuration")
  • Measurement ID: your G-XXXXXXX (find it in GA4 → Admin → Data Streams → Web)
  • Trigger: Initialization — All Pages

Save and Publish the container. Reload the WP site. In GA4 → Realtime, you should see page_view events appearing within ~30 seconds.

If page_view doesn't appear, the GTM container isn't routing to your GA4 property — fix that before continuing.

Step 2 — Generic ecommerce event forwarder

Create one GA4 Event tag that forwards all CR Bee events:

Tag:

  • Tag type: GA4 Event
  • Configuration tag: the one from Step 1
  • Event Name: {{Event}} (click the + icon next to the field and select the built-in Event variable)
  • More settings → Ecommerce → Send Ecommerce data: check this box, set source to Data Layer

Trigger:

  • Trigger type: Custom Event
  • Event name (regex match): ^(view_item_list|view_item|add_to_cart|begin_checkout|purchase|checkout_contact)$
  • Check Use regex matching

Attach the trigger to the GA4 Event tag. Save and Publish.

Step 3 — Use DebugView to verify ecommerce details

GA4 Realtime shows event counts but truncates ecommerce details. For verifying items[], value, and other fields, use DebugView:

Then visit GA4 → Admin → DebugView. Walk the booking funnel — you'll see each event with its full payload as it arrives.

Connecting events to GA4 without GTM

If your site uses gtag.js directly (no GTM) — for example via Site Kit or a hardcoded gtag snippet — events pushed to dataLayer should be picked up automatically. gtag.js reads from dataLayer internally.

If events still don't appear in GA4 in this setup, check:

  • The gtag config call (gtag('config', 'G-XXX')) runs before the CR Bee events are pushed. Order matters — page-load events from results / vehicle details / checkout / confirmation pages happen during page render, so gtag must already be initialized.
  • The GA4 property's data stream Measurement ID matches the one in your gtag('config', ...) call.
  • Browser ad blockers aren't dropping the GA4 requests (check the Network tab for blocked /g/collect calls).

No consent gating (default). Events push to dataLayer regardless of consent state. Use this if your GTM container handles consent itself via Google Consent Mode v2 — GTM decides what to forward to GA4.

Require WP Consent API approval. Events only fire when wp_has_consent('statistics') returns true. Use this when your site has a WP Consent API-compatible CMP like Complianz or Real Cookie Banner, and you want the plugin to honor banner choices directly. If no CMP is installed, the plugin shows an amber warning in the admin and falls back to firing events.

Purchase event reliability

The plugin stashes the cart snapshot in sessionStorage during checkout, then reads it on the confirmation page to fire purchase with the full items[] array. This works for the standard request and pay_at_pickup redirect flow.

Limitations:

  • For pay_now and deposit booking modes, the customer is redirected to Stripe — the cart is stashed but isn't renamed under the booking reference until the customer returns. On the post-Stripe confirmation page, purchase fires with transaction_id and currency only (no value or items). GA4 still records the conversion.
  • If the customer opens the confirmation URL in a new tab (different sessionStorage), same fallback applies.
  • Ad blockers that strip inline scripts will drop the event. Server-side Measurement Protocol is on the roadmap for a future release.

Filters

For developers who need finer control, two PHP filter hooks are exposed:

crbc_should_track

Last-word boolean override. Returning strict false disables tracking regardless of the admin toggle. Non-bool returns fall back to the option value.

// Disable tracking for logged-in administrators only.
add_filter( 'crbc_should_track', function ( $enabled ) {
    if ( current_user_can( 'manage_options' ) ) {
        return false;
    }
    return $enabled;
} );

crbc_track_payload

Modify any event payload before it's pushed to dataLayer. Receives $payload (the full push including event and ecommerce) and $event_name. Must return an array — any other return type (null, false, string, etc.) drops the event.

// Add affiliation to all purchase events.
add_filter( 'crbc_track_payload', function ( $payload, $event_name ) {
    if ( $event_name === 'purchase' ) {
        $payload['ecommerce']['affiliation'] = 'CR Bee';
    }
    return $payload;
}, 10, 2 );

// Drop add_to_cart events entirely.
add_filter( 'crbc_track_payload', function ( $payload, $event_name ) {
    if ( $event_name === 'add_to_cart' ) {
        return null; // any non-array return drops the event
    }
    return $payload;
}, 10, 2 );

Troubleshooting

Events appear in dataLayer but not in GA4 Realtime. GTM isn't forwarding them. Follow the GTM setup steps above. The most common cause is a missing GA4 Configuration tag.

Events appear in dataLayer and a page_view reaches GA4, but custom events don't. You have the GA4 Configuration tag but no GA4 Event tag. GTM doesn't auto-forward arbitrary dataLayer events — each event (or a regex group) needs its own Event tag and Custom Event trigger.

Events fire on first page load but stop after navigation. This is unrelated to the plugin — usually a GTM tag with a "Page View - Window Loaded" trigger that doesn't re-fire on SPA navigation. The CR Bee booking flow is server-rendered, not SPA, so each page is a fresh page load. If your theme is single-page, check your GTM triggers.

purchase event has empty items[] and value. The customer used pay_now or deposit mode (Stripe redirect) — see Purchase event reliability. Or the customer opened the confirmation page in a new tab.

Toggle is on but I want to disable tracking for a specific user. Use the crbc_should_track filter — see Filters.

On this page