Fixing GA4 “(not set)” purchase attribution for Measurement Protocol events

A GA4 purchase tracking issue appeared when purchase events were sent through the Measurement Protocol. The events were collected, but source and medium attribution were not correctly assigned.

The challenge

For ecommerce and performance marketing reporting, purchase attribution is critical.

When GA4 cannot connect a purchase event to the correct session, source or medium, the business loses visibility into which campaigns and channels are actually driving revenue.

The problem was connected to the session_id. After updating the Consent Mode template, the previous method used to access the gtag() function was no longer available, which meant the setup could no longer retrieve the session ID required for proper attribution.

GA4 not set purchase attribution issue
GA4 “(not set)” purchase attribution issue.

What I investigated

  • GA4 purchase events
  • Measurement Protocol attribution
  • session_id availability
  • GTM custom templates
  • Consent Mode template updates
  • DataLayer events
  • Source / medium reporting in GA4

The solution

I implemented a new way to retrieve the GA4 session ID using the custom template GTAG GET API.

This template requests the session ID from GTAG through the API and pushes a gtagApiGet event into the dataLayer.

The event contains gtagApiResult.session_id, which can then be used for the purchase event attribution flow.

The implementation was adjusted so the session ID could be stored and used correctly for Measurement Protocol purchase events.

GTAG GET API template configuration
GTAG GET API template configuration.
session_id returned into the dataLayer
GTAG API Get and session ID implementation.

Result

After the solution was implemented and tested, GA4 transaction attribution by source / medium returned to the expected level compared with the period before the issue appeared.

This restored confidence in purchase reporting and helped the business make better decisions based on accurate campaign and channel performance.

GA4 source medium attribution restored
Restored source / medium attribution in GA4.

← Back to case studies

Case Study 02

Fixing GA4 “(not set)” purchase attribution for Measurement Protocol events

A GA4 purchase tracking issue appeared when purchase events were sent through the Measurement Protocol. The events were collected, but source and medium attribution were not correctly assigned.

The challenge

For ecommerce and performance marketing reporting, purchase attribution is critical.

When GA4 cannot connect a purchase event to the correct session, source or medium, the business loses visibility into which campaigns and channels are actually driving revenue.

The problem was connected to the session_id. After updating the Consent Mode template, the previous method used to access the gtag() function was no longer available, which meant the setup could no longer retrieve the session ID required for proper attribution.

GA4 not set purchase attribution issue
GA4 “(not set)” purchase attribution issue.

What I investigated

The solution

I implemented a new way to retrieve the GA4 session ID using the custom template GTAG GET API.

This template requests the session ID from GTAG through the API and pushes a gtagApiGet event into the dataLayer.

The event contains gtagApiResult.session_id, which can then be used for the purchase event attribution flow.

The implementation was adjusted so the session ID could be stored and used correctly for Measurement Protocol purchase events.

GTAG GET API template configuration
GTAG GET API template configuration.
session_id returned into the dataLayer
GTAG API Get and session ID implementation.

Result

After the solution was implemented and tested, GA4 transaction attribution by source / medium returned to the expected level compared with the period before the issue appeared.

This restored confidence in purchase reporting and helped the business make better decisions based on accurate campaign and channel performance.

GA4 source medium attribution restored
Restored source / medium attribution in GA4.

← Back to case studies