Connecting Moodle to GA4
Moodle is self-hosted open-source learning management, used mostly by institutions where enrolment and payment are usually two different systems. GA4 is where the business goes to understand what happened, which makes an unattributed conversion there expensive in decisions rather than in ad spend. The join between them succeeds or fails on one thing: whether the GA4 client_id reaches the Moodle enrolment before the conversion happens, because GA4 can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Moodle in GA4: paid enrollments, not every course join
Send the paid enrollment server-side after the payment plugin confirms, as purchase with the course fee and payment or enrollment ID as transaction_id. Use the public marketing site's client_id stored in a profile custom field at sign-up, since SSO redirects drop _gl. Don't send student data covered by FERPA.
Most Moodle sites add GA4 through the Additional HTML setting or the theme, so the tag runs on every logged-in page, including the enrollment confirmation. That page loads for self-enrollment, cohort sync and manual enrollment alike, so a key event built on it counts free activity. Send the paid enrollment server-side instead, after the payment gateway confirms through the Enrolment on payment plugin or whichever payment plugin you use, as purchase with the course fee as value and the payment or enrollment ID as transaction_id.
The client_id has to be the one from the public marketing site, stored in a user profile custom field at sign-up, not the one set on the Moodle subdomain. If the two are on different domains, configure cross-domain measurement; if institutional SSO sits between them, the redirect through the identity provider usually drops the _gl parameter, and the profile field is the only thing that survives. Measurement Protocol does not create a session, so the purchase inherits attribution from that stored client_id.
For US institutions, do not send the Moodle user ID, student numbers or course names that reveal something about a student without your registrar's review; enrollment data can be an education record under FERPA. A course ID and a fee are enough for acquisition reporting.
Moodle → GA4 · what breaks
Why this join usually fails — Moodle → GA4
- 01
The GA4 client_id never reaches Moodle
Moodle is typically behind a login and often behind a separate marketing site, so the click identifier has to survive from a public page through registration into a user profile field. Institutional single sign-on frequently breaks that chain entirely.
- 02
Free enrolments outnumbering paid ones
Self-enrolment, cohort sync and manual enrolment all create the same record type as a paid one. Counting them teaches bidding to find people who join free courses.
- 03
Everything lands under (direct)/(none)
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
- 04
Nothing reconciles afterwards
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Moodle → GA4 · the fix
What working looks like — Moodle → GA4
The GA4 client_id on every enrolment
Conversions arriving in GA4
Conversions appear in GA4 attributed to the original session's source and medium, so acquisition reporting reflects what actually drove revenue.
Reconciled against the source
Moodle → GA4 · architecture
How Moodle and GA4 actually connect
- 1
Moodle holds the truth
Moodle supports several enrolment methods at once — self-enrolment, manual, cohort sync, payment plugins — and most of them are free. Only the paid methods represent revenue and the others will swamp any blended count.
- 2
GA4 needs a click to match
GA4 needs the client_id to attach a server event to the user and session that produced the click. Without it there is no attribution to inherit and the event is orphaned.
- 3
The identifier is the bridge
The GA4 client_id, captured at the visit and carried into the Moodle enrolment.
- 4
The event source decides reliability
Send paid enrolments only, from the server. Free and cohort-synced enrolments must be excluded or the conversion feed is dominated by activity that is not revenue.
- 5
Deduplication at the destination
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Moodle → GA4 · normal or broken
Working vs. broken, side by side — Moodle → GA4
Normal, not a fault
The GA4 client_id present on the enrolment
Sent from the Moodle enrolment event via a webhook plugin or scheduled export
Deduplicated correctly
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Reconciles with the source
Actually broken
The GA4 client_id missing on most records
Moodle is typically behind a login and often behind a separate marketing site, so the click identifier has to survive from a public page through registration into a user profile field. Institutional single sign-on frequently breaks that chain entirely.
Sent from the browser
Self-enrolment, cohort sync and manual enrolment all create the same record type as a paid one. Counting them teaches bidding to find people who join free courses.
Counted twice, or not at all
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
Nobody has reconciled it
Moodle → GA4 · diagnose
Diagnostic order — Moodle → GA4
- 01
Count enrolments carrying the GA4 client_id
- 02
Follow one real conversion end to end
- 03
Break down enrolments by enrolment method
If paid methods are a small minority, that minority is the only thing that should ever reach an ad platform.
- 04
Check whether server events carry a session and a source
In GA4 Realtime or DebugView, find the event and look at its session and traffic source. A brand-new user with no source on every server event is the missing-client_id signature.
- 05
Read the match rate, not the success message
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Moodle → GA4 · prove
How it gets proven — Moodle → GA4
Source of truth
Moodle's enrolment records in your own database, filtered to paid enrolment methods.
- The GA4 client_id confirmed present on a live enrolment.
- Server events confirmed in DebugView attaching to an existing session with the original traffic source intact.
- Paid enrolments confirmed separated from free and cohort-synced ones before anything is sent.
Moodle → GA4 · free audit
What we check in the free audit
- Count enrolments carrying the GA4 client_id
- Follow one real conversion end to end
- Break down enrolments by enrolment method
- Check whether server events carry a session and a source
- Read the match rate, not the success message
Checked against
Moodle's enrolment records in your own database, filtered to paid enrolment methods.
Free30 minutesNo obligation
Moodle → GA4 · when not to buy
When you don't need this — Moodle → GA4
- Measure identifier coverage yourself first — pull your last hundred enrolments and count how many carry the GA4 client_id.
- If your Moodle is purely internal training with no paid enrolment, there is no conversion here to measure.
- GA4 is reporting, not bidding. If your problem is ad platform optimization, fix the ad platform destination first — GA4 will not change what any campaign does.
Moodle → GA4 · what we deliver
What gets built — Moodle → GA4
Identifier capture into Moodle
Capture the identifier on the public site and write it to a Moodle user profile custom field at account creation, so later paid enrolments can be traced back.
Event source: the Moodle enrolment event via a webhook plugin or scheduled export
Send paid enrolments only, from the server. Free and cohort-synced enrolments must be excluded or the conversion feed is dominated by activity that is not revenue.
Dispatch to GA4
Measurement Protocol events with the client_id, session_id and the correct measurement ID and API secret, sent server-side.
Reversals where they exist
Un-enrolments and refunds where a payment plugin is used should reduce the reported figure.
Written guarantee
95%+ tracking accuracy
Measured against Moodle's enrolment records in your own database, filtered to paid enrolment methods.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Moodle → GA4 questions, answered
Send a purchase event by Measurement Protocol when the payment plugin confirms, using the client_id stored on the user profile at sign-up. Do not use the enrollment page view, which also fires for free enrollments.
The client_id sent with the event is missing or comes from the Moodle subdomain, so GA4 cannot connect it to the marketing-site visit. Store the marketing-site client_id at account creation.
Almost always because the GA4 client_id never reached the Moodle enrolment. Moodle is typically behind a login and often behind a separate marketing site, so the click identifier has to survive from a public page through registration into a user profile field. Institutional single sign-on frequently breaks that chain entirely. Measure coverage before debugging the dispatch.
The client_id, from the _ga cookie. Measurement Protocol events without it are rejected or create a brand-new user with no session and no source, which is how server events end up filed under (direct)/(none) and make paid channels look worse than they are. Send session_id alongside it so the event joins the existing session, and include engagement_time_msec or the event may not appear as expected in reports.
The Moodle enrolment event via a webhook plugin or scheduled export. Send paid enrolments only, from the server. Free and cohort-synced enrolments must be excluded or the conversion feed is dominated by activity that is not revenue.
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
More on Moodle → GA4
- Stripe → GA4Connecting Stripe to GA4
- PayPal → GA4Connecting PayPal to GA4
- HubSpot → GA4Connecting HubSpot to GA4
RELATED GUIDES
Where Moodle → GA4 fits in the rest of your tracking
- Canvas → GA4Connecting Canvas LMS to GA4
- LearnWorlds → GA4Connecting LearnWorlds to GA4
- LifterLMS → GA4Connecting LifterLMS to GA4
- Moodle → PostHogConnecting Moodle to PostHog
- Moodle → AmplitudeConnecting Moodle to Amplitude
- BootcampsConversion tracking for bootcamps, measured in started students
- Tovuti → GA4Connecting Tovuti to GA4
- TalentLMS → GA4Connecting TalentLMS to GA4
Free · 30 min
Get Moodle and GA4 joined properly
Free30 minutesNo obligation
