How To Bind Twitter Basic Pixel in Customer events

Cameron9945
Shopify Partner
3 0 1

I have added Twitter's basic code in Customer events. But when I use Chrome's Twitter plug-in tool to detect the pixel, I always get this error. How to fix it?

Btw, there is no problem adding the code directly to [theme.liquid]. I want to know why?

P.S. error message: 

1. Warning. No Referrer found. This is expected if you are loading this page directly. If this occurs after redirecting from a Twitter Ad or other page, this may indicate an error.

2. An iFrame was detected. Remove the tag from the iFrame to properly track URLs.

pic2.pngpic1.pngpic3.png

Replies 3 (3)

robwatkins88
Shopify Partner
16 0 0

The tracking snippet needs to run before the event fires. When you add it through a property in the cms the load order is defined by the app or platform, in code the conversion metric will follow after the library is loaded. 

Cameron9945
Shopify Partner
3 0 1

Thanks for your answer. Can you please tell me how to adjust my Twitter code?

robwatkins88
Shopify Partner
16 0 0

window.addEventListener('load', (e) => {
if(window.twitter == null) {
window.twitter = [];
}

window.twitter();
})