Testing custom pixels

After you create a pixel, test it to ensure that customer events trigger correctly on your online store. Review the following tips for testing and troubleshooting custom pixels.

Ensure that a custom pixel is connected

  1. From your Shopify admin, go to Settings > Customer Events.
  2. In the row of the pixel that you're testing, ensure that the Status column is Connected.
  3. If the pixel isn't connected, then click ..., and then click Connect.

Testing your custom pixel using a browser console log

You can test whether your custom pixel is loading and subscribed to a customer event by using a browser console log. The steps to check your console depend on the web browser that you use. For example, to learn how to use the console for Google Chrome, refer to the Chrome for Developers Console overview.

It can take some time for your browser cache to clear, so you might need to check your console multiple times, or use another browser window or device before a pixel loads.

Test whether a custom pixel is loading

Certain factors such as GDPR settings or a third-party script can block a pixel from loading. You can add a snippet of code to a pixel to test whether it's loading correctly. This snippet adds a message that's readable in the console of your browser. If the message displays in the browser console, then it means that the pixel is loading successfully on your website.

Steps:

  1. From your Shopify admin, go to Settings > Customer Events.
  2. Click the pixel that you're testing, and then in the Code section, enter the following statement to the first line before any other code: console.log("loaded");.
  3. Click Save.
  4. Visit your online store, and then use your browser console to verify that your console.log statement displays.

Troubleshooting your pixel when it doesn't load

If your pixel doesn't load after testing with the console.log("loaded"); code, then there could be customer privacy settings preventing it from loading.

From your Shopify admin, go to Settings > Customer privacy to check for customer privacy settings in your Shopify admin that might apply to your session. Depending on your customer privacy settings, take the following steps:

  • If you have customer privacy settings that require consent in your region, then ensure that you've provided consent through your cookie banner.
  • If you don't have any customer privacy settings that block the pixel from loading, then clear your browser's cookies to reset your cookie banner and provide consent.

If you use a third-party tool to manage consent, then contact your third-party provider for support.

Test whether a pixel is subscribed to a customer event

To test that a custom pixel is subscribed to a customer event, you can add the following code to your custom pixel, replacing page_viewed with the event that you want to test:

analytics.subscribe("page_viewed", async (event) => { console.log(event); });

Steps:

  1. From your Shopify admin, go to Settings > Customer Events.
  2. Click the pixel that you're testing, and then in the Code section, enter the customer event subscription test code.
  3. Click Save.
  4. Visit your online store, and then review your browser console to verify that your console.log statement displays.

Additional troubleshooting

If it's still unclear whether your custom pixel is properly subscribed to a customer event, then try the following troubleshooting measures:

  • Clear your browser's cookies.
  • If you're testing a standard event, then review Shopify's standard event descriptions developer documentation to ensure that you're performing the required steps to trigger the event.
  • If you're testing a custom event, then verify that your publish() code is firing by placing a console.log statement before and after your publish code in your theme.liquid files or checkout extensions. For example:
    console.log("before publish"); Shopify.analytics.publish("my_custom_event", myCustomData); console.log("after publish");

Third-party pixel SDK testing

A pixel SDK (software development kit) contains the tools for your pixel to collect information about customer behavior. You can test the following behaviors of a third-party provided pixel SDK:

Test whether a third-party pixel SDK is loaded

The steps to check your network tab depend on the web browser that you use. For example, to learn how to check your network tab on Google Chrome, refer to the Chrome for Developers Inspect network activity documentation.

To test that a third-party pixel SDK is loaded, you first need to retrieve your third-party provider's code for the SDK URL so that you can add it to your pixel code. For support, contact your third-party pixel provider.

Steps:

  1. From your Shopify admin, go to Settings > Customer Events.
  2. Click the custom pixel that you want to test.
  3. In the Code section, enter the pixel SDK that your third-party provider provided to the end of your pixel code.
  4. Click Save.
  5. Visit your online store, and then check your network tab to ensure that the third-party provider's SDK URL is being downloaded.
  6. Optional: If the third-party pixel SDK doesn't load, then check for JavaScript runtime errors in the sandbox. For example, on Chrome you can select a particular iFrame to review console logs for, and then narrow the logs to the specific pixel that you're testing. To learn more about checking for JavaScript runtime errors on Chrome, refer to Chrome's Debug JavaScript documentation.

If the third-party pixel SDK doesn't load during testing, then reach out to your third-party pixel provider for support.

Other third-party pixel SDK testing

To test whether a third-party pixel SDK is initialized or collecting events, refer to your third-party pixel provider's documentation.

To test whether a pixel SDK is collecting events, you might be instructed to check your browser's network tab. The steps to check your network tab depend on the web browser that you use. For example, to learn how to check your network tab on a Google Chrome browser for Google Chrome, refer to the Chrome for Developers Inspect network activity documentation.

Can't find answers you're looking for? We're here to help you.