ReferenceError: alert is not defined in Shopify Web Pixel Extension (No alert in my code)

Hi everyone,

I’m developing a Shopify Web Pixel extension using the @shopify/web-pixels-extension package. My extension code is very simple and does not use alert anywhere. Here’s my main file:

import {register} from "@shopify/web-pixels-extension";

register(({ analytics, browser, init, settings }) => {
    // Bootstrap and insert pixel script tag here

    // Sample subscribe to page view
    analytics.subscribe('page_viewed', (event) => {
      console.log('Page viewed', event);
    });
});

However, when I run my extension, I get the following error in the browser console:

Uncaught (in promise) ReferenceError: alert is not defined
    at Object.<anonymous> (web-pixel-1027375272@013d4bc47cfee3b6f48ae6745405f09e.js:1:1062)
    at Generator.next (<anonymous>)
    at web-pixel-1027375272@013d4bc47cfee3b6f48ae6745405f09e.js:1:758
    at new Promise (<anonymous>)
    at a (web-pixel-1027375272@013d4bc47cfee3b6f48ae6745405f09e.js:1:578)
    at Object.<anonymous> (web-pixel-1027375272@013d4bc47cfee3b6f48ae6745405f09e.js:1:924)
    at J (worker.modern.js:1:66592)
    at b (worker.modern.js:1:67987)

I have confirmed that there is no alert in my code. It seems to be coming from a bundled or third-party script, possibly a pixel or analytics script.

Also their are lots of other console which i am not console from anywhere.

Has anyone else encountered this?

  • Is this a known issue with Shopify’s pixel infrastructure or a third-party script?
  • Any suggestions for how to resolve or work around this error?

Thanks in advance for your help!

Hi Adarsh,

The error ReferenceError: alert is not defined in a Shopify Web Pixel Extension is occurring because of how Web Pixels Manager handles third-party pixel code.

Looking at your screenshot, this error is coming from a third-party pixel that’s loaded on your shop - specifically from a file named web-pixel-1027375272@013d4bc47cfee3b6f48ae6745405f09e.js. This is not your extension code, but another app’s pixel trying to run on the same page.

The error occurs because the other app’s pixel is attempting to use the alert() function, which is not available in Web Workers (used by third-party app pixels).

In Web Workers, window-specific APIs like alert() are not available (they’re part of the Window interface). Therefore, pixels that run in Web Workers don’t have access to these functions.

To resolve this issue:

  1. This error is not coming from your pixel code, so you don’t need to fix anything in your extension.
  2. It’s likely that another app installed on your development store has a pixel that’s unaware of the context it is running in (trying to use alert() in a context where it doesn’t exist).
  3. The error won’t affect your pixel’s functionality, though it might be noisy in your console.

If you’re developing locally and want to reduce console noise, you could temporarily disable other pixels in your development store during testing. If this is occurring in production, you might want to inform the other app’s developer that their pixel is causing console errors by trying to access window functions in a Web Worker context.

1 Like

@bdestrempes Thanks for responding.

But it was going off when I uninstalled my app. Is it normal.

Hi @adarsh_anncode,

Looking carefully at your logs, there are two different sources generating console output:

  1. Your pixel extension - which is logging the page_viewed event
  2. Another pixel (web-pixel-1027375272@…) - which is generating the browser/settings/analytics logs and the alert error

This would confirm that you have at least two different app pixels running on your store:

  1. Your extension (working correctly)
  2. Another app’s pixel (triggering the alert error)

When you uninstalled your app, you were still seeing errors because the problematic pixel belongs to a different app that remained installed.

This error appears to be completely unrelated to your code and could be safely ignored as it won’t affect your extension.

If you want to eliminate the error, you would need to identify which other app is adding this pixel (ID: 1027375272) and either contact its developer or consider uninstalling it if it’s not needed.

I created a extension in same app and remove this after a day and again create new extension.
The id showing is of my previous created extension.

@adarsh_anncode I’d like to help investigate this issue properly. Could you share your development store URL with me if you’re comfortable doing so? This would help me understand what’s happening with the removed extension still generating errors.

If you prefer not to share your dev store URL (which is completely understandable for privacy/security reasons), it would be best to continue this conversation through official support channels.

here is my development store. currently dev app is installed in which i add extension.

If any thing more, please ask anytime.

Hi @adarsh_anncode,

Thanks for providing the link to your development store. I took a look and there are currently 3 app pixels installed on your store:

  1. Discount Kit (ID 584712360, works fine)
  2. easybulkfil_test (ID 1031897256, works fine)
  3. product-recommendation-pixel (ID 1027375272, throwing alert() error)

Looking at the JavaScript being loaded on your shop for pixel id 1027375272, we can definitely see that the pixel is calling alert():

var d = D(y => {
    "use strict";
    T();
    m(i => a(y, [i], function*({analytics: e, browser: o, settings: r}) {
        console.log("browser: ", o),
        console.log("settings: ", r),
        console.log("analytics: ", e),
        alert("Hello from the web pixel extension!")
    }))
}
);

This leads me to think that the code you shared in your initial post is not the actual code the pixel is trying to execute. I could not find any pixel code related to the page_viewed log in your example. Has the app been updated with this new code?

To continue our investigation, could you do the following:

  1. Start your local environment dev server with your custom app
  2. In your browser’s developer tools, look for your custom app in the “Sources” panel (like shown in the above screenshot)
  3. Share the code you see there
1 Like

@bdestrempes Thank you so much for your help. Your explanation about the alert issue in the Web Worker context really clarified things for me. I appreciate the support!

2 Likes

Hi, @bdestrempes Can you tell me about the Pixel Helper seen in the given image.

Go to your pixel in Customer Events, then click ‘Test’ at the top right.

1 Like

Hey @Luke

I have two store, where the same app installed in them as well running.
But in one store setting>customer event button is disabled, and in 2nd store have app showing disconnected.