Implementing Conversion Pixel (Javascript) With Workers?


Can someone please explain if it is possible to inject a conversion tracking pixel using workers?
If so, how?
What is the exact code to be used in my worker for the following script:

Please help, looking forward to the code that will inject this in the html right after tag…
Kind Regards,

< script type=“text/javascript” src=“” data-goal=“007” >< /script >


you’d use to select the tag you want to insert your js script (i.e. body) and use the append method. From docs:

append(content: Content, contentOptions?: ContentOptions): Element: Inserts content right before the end tag of the element.

Hope that helps.

Is using a worker a requirement for that?

A lesser known option but probably easier in your case would be to use a Cloudflare App,

1 Like