Shopify: Fix Sandbox URLs issue in GA4

Google Analytics BCS 8 months ago (06-05) 1507 Views 0 Comments

Updated: December 19, 2025

Issue

In GA4 reports, the URLs appear garbled, with a structure like:

/wpm@10e09e41w77fb031apd6c28ceam532d5d9a/custom/web-pixel-118849878@4/sandbox/modern/page-name

 

Reason

This happens because GA4 is installed via Shopify Custom Pixel, which runs in Sandbox mode. URLs in Sandbox are irregular, causing GA4 reports to display these garbled paths.

 

Solution

To fix this, you should disable default page tracking and use custom events to send clean URLs.

Step 1: Disable Default Page Tracking

Since Custom Pixel runs in Sandbox, the default page tracking will capture irregular URLs.

To prevent this, set send_page_view to false in GA4 so that default page views are not sent, but Google Tags still load.

In GTM, click「Tags」——「New」——「Choose a tag type to begin setup…」——「Google Analytics」——「Google Tag」, name it “Disable Default PageView”, and then make the following settings:

Shopify: Fix Sandbox URLs issue in GA4

 

Step 2: Use Custom Events to Track Actual Pages

Copy the following code into Shopify’s Custom Pixel:

analytics.subscribe('page_viewed', (event) => {
  window.dataLayer.push({
   'event': 'page_viewed',
   'page_location': event.context.window.location.href,
   'page_title': event.context.document.title,
  });
});

Step 3: Configure GTM Variables

In GTM, click「Variable」——「New」——「Choose a variable type to begin setup…」——「Data Layer Variable」, name it “dlv_page_location”, and then make the following settings:Shopify: Fix Sandbox URLs issue in GA4

Similarly, create the data layer variable dlv_page_title.

Step 4: Create a Custom Trigger

In GTM, click「Trigger」——「New」——「Choose a trigger type to begin setup…」——「Custom Event」, name it “page_viewed”, and then make the following settings:Shopify: Fix Sandbox URLs issue in GA4

 

Step 5: Create GA4 Event Tag

In GTM, click「Tags」——「New」——「Choose a tag type to begin setup…」——「Google Analytics」——「Google Analytics: GA4 Event」, name it “GA4-Event-PageView”, and then make the following settings:Shopify: Fix Sandbox URLs issue in GA4

With this setup, GA4 reports will display clean, readable URLs, excluding Sandbox paths.

Like (1)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website