Skip to content

Add Microsoft UET to registry #165

@joachimhviid

Description

@joachimhviid

Script can be found here

I attempted to implement it myself like below, but I am running into problems with UET not being available from the script that is being set, since it is part of the script being loaded.

const { uetq, $script } = useRegistryScript('bing', () => ({
  scriptInput: {
    src: 'https://bat.bing.com/bat.js',
    async: true,
    crossorigin: false,
  },
  scriptOptions: {
    use() {
      return { uetq: window.uetq }
    },
  },
  clientInit: import.meta.server
    ? undefined
    : () => {
        window.uetq = window.uetq || []

        const options = { ti: 'YOUR_KEY_HERE', enableAutoSpaTracking: true }
        // @ts-expect-error untyped
        options.queue = window.uetq
        // @ts-expect-error untyped
        window.uetq = new UET(options)

        window.uetq.push('consent', 'default', { ad_storage: 'denied' })
      },
}))

The original script creates a brand new script element with https://bat.bing.com/bat.js as the source and then sets the window.uetq from there, but I am unsure how to recreate that in a registry script.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions