How Does Elevar Server-Side GA4 Attribution Work?

Overview

How does Elevar decide what to capture in order notes and what to send to GA?

If you are using one of Elevar's server side destinations, you will notice some information stored in order notes within Shopify (e.g. a variety of click IDs, cookie values, and UTM parameters).


Google Analytics 4:

Let's zoom in on Google Analytics 4 specifically. GA4 uses a couple of cookie values to associate hits with the correct user and session that we always capture when available:

  • _ga (stored via _elevar__ga) - used by Universal Analytics and GA4
  • _ga_XXXX (stored via _elevar__ga_XXXX) - used by GA4

GA4 uses query parameters in the URL and the referrer to attribute hits to various channels. We'll call the contents of this list "GA parameters" going forward. These are stored via _elevar_visitor_info in order notes:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_content
  • utm_term
  • gclid
  • referrer

Elevar's dataLayer mimics Google's processing to store the GA4 parameters for the session and then push them to order notes:

  • If there are any utms or a gclid in the URL, we clear out all GA4 parameters we previously stored in local storage, and store the new ones from the URL
  • If there are no utms and no gclid, but there is an external referrer (for example, google.com from an organic listing), we clear out all GA4 parameters we previously stored in local storage, and store the referrer
  • If there are no utms, gclid, or external referral, nothing is changed in local storage. We may have GA4 parameters stored from a previous session

What do we send with the transaction to GA4?

When processing orders for attribution in Google Analytics 4 (GA4), several scenarios are considered:

Attribution Overrides:

If the order matches any attribution overrides in the destination settings, GA4 cookies are sent along with the outlined attribution information.

Existing GA Cookies:

If the required GA cookies are available for the order, GA4 cookies and any stored GA4 parameters are sent. This ensures accurate channel attribution, even if previous session hits were blocked. If session hits were not blocked, GA4 will link the purchase hit to the user's other session hits. However, if no GA4 parameters are available, the order may appear as direct/none in GA4, unless GA4 has previous attribution information not available elsewhere.

Missing GA4 Cookies, but with Parameters:

In cases where GA4 cookies are absent but GA4 parameters are present, the order is sent with the parameters, albeit with a generated cookie value. This method ensures correct channel attribution but generates a new user and session in GA4.

No GA4 Cookies or Parameters:

If neither GA4 cookies nor parameters are available, the system checks Shopify's "landing_site" to see if any GA4 parameters were captured. If found, these parameters are sent with the order along with a generated cookie value. However, without GA4 cookies or parameters, the order will result in a new user and session in GA4, attributed to direct/none. Utilizing Shopify's landing_site as a fallback increases the chance of attributing the order to a channel.