> For the complete documentation index, see [llms.txt](https://help.orbe.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.orbe.app/general/connect-stores/google-analytics.md).

# Google Analytics 4

Keep Google Analytics 4 sessions when visitors move to another country storefront.

When Connect Stores sends a visitor from one domain to another (`brand.com` to `brand.ca`), Google Analytics 4 can start a **new session** on the destination. Source, campaign, and ads data often look like a referral from your own store.

Orbe adds GA4’s linker parameter (`_gl`) to those redirects so the session can continue. You still need cross-domain measurement enabled in GA4.

{% hint style="info" %}
Keeping UTM parameters in the URL is not the same as keeping the GA4 session. Orbe can preserve the path and UTMs, and the session can still split without `_gl`.
{% endhint %}

## What Orbe does

On a **hostname change**, if the origin storefront has GA4 loaded (`gtag` and a `G-` measurement ID), Orbe appends `_gl` before sending the visitor to the other country storefront.

This covers:

* Geolocation popup, when the visitor continues to another domain
* Country selector, when the destination is another domain
* Automatic redirect on a later visit, when the destination is another domain

Orbe does **not** add `_gl` when:

* The visitor stays on the same hostname (for example a Markets subfolder such as `/en` to `/fr`)
* GA4 is not on the page (no `gtag`, or only Google Ads `AW-` tags)
* Decoration fails or times out. The redirect still happens.

There is nothing to enable in Orbe for this. Stores without GA4, or without cross-domain redirects, are unchanged.

## Set up GA4

Orbe only stamps `_gl` on the outbound URL. Session stitching still needs Google’s cross-domain settings on **both** hostnames.

{% stepper %}
{% step %}

### Use the same property

Install the same GA4 property (or linked properties) on every connected country storefront.
{% endstep %}

{% step %}

### List both domains

In the Google tag, open **Configure your domains** (linker settings) and add each hostname, for example `brand.com` and `brand.ca`.
{% endstep %}

{% step %}

### Confirm linker acceptance

With those domains listed, GA4 accepts incoming linker parameters by default. The destination storefront must load the same Google tag.
{% endstep %}

{% step %}

### Exclude self-referrals

The domain list usually stops the origin hostname from counting as a referrer. If `.com` still appears as the source of `.ca` traffic, recheck this list first.
{% endstep %}
{% endstepper %}

Without this GA4 setup, `_gl` is ignored and sessions still split.

Google’s guide: [Set up cross-domain measurement](https://support.google.com/analytics/answer/10071811).

## How to check

1. Open a connected storefront that has GA4 loaded.
2. Use the geolocation popup or country selector to go to another domain.
3. On the destination URL, look for `_gl=` (address bar or DevTools → Network).
4. In GA4 DebugView or Realtime, the destination hit should keep the original session and source, not a referral from your origin hostname.

If `_gl` is missing:

* Confirm it was a **domain** change, not a subfolder on the same hostname.
* Confirm `gtag` and a `G-` ID load on the origin page before the visitor clicks through.
* If you load GA4 only through GTM, use the custom event below.

## Custom GTM setups

Load this script **before** the visitor is sent to the other storefront (theme custom JS, Orbe custom JS, or GTM). Listening after the click is too late.

The event fires on every Orbe navigation. Native `_gl` decoration still runs afterward if the hostname changed and `_gl` is not already on the URL.

```javascript
window.addEventListener('orbe:before-redirect', (event) => {
  event.detail.decorate = async (url) => {
    return url;
  };
});
```

Use `event.detail.decorate` when GTM or another tag needs to change the destination URL asynchronously. Return a URL string.

## FAQs

<details>

<summary>Does Orbe keep UTM parameters?</summary>

Yes, when redirect with full path is enabled in [Connect Stores settings](/general/connect-stores/settings.md). That is independent of GA4 sessions.

</details>

<details>

<summary>Why is my .com store showing as the referrer on .ca?</summary>

GA4 treated the destination as a new session. Confirm `_gl` is on the landing URL, then confirm both domains are listed in GA4 cross-domain measurement.

</details>

<details>

<summary>Do I need this for Shopify Markets on one domain?</summary>

No. Same-hostname country experiences already share first-party cookies. This only matters when Connect Stores sends visitors to a **different hostname**.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.orbe.app/general/connect-stores/google-analytics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
