Skip to content

metaPixel

The metaPixel registry script. It loads https://connect.facebook.net/en_US/fbevents.js for the input of the example. Call useScriptMetaPixel(input, options?) from @hamur/scripts/<library> in a component, or list it under scripts.registry.metaPixel to load it on every page.

Config keyscripts.registry.metaPixel
FunctionuseScriptMetaPixel of @hamur/scripts/<library>
Input keysid (required)
Default triggerclient
Scripthttps://connect.facebook.net/en_US/fbevents.js
Hostsconnect.facebook.net, www.facebook.com
Bundleyes: scripts.bundle: ["metaPixel"]
Collection proxyno
Consentnone

Example

ts
import { defineConfig } from "hamur";
import scripts from "@hamur/scripts";

export default defineConfig({
  framework: "react",
  modules: [scripts],
  scripts: {
    registry: {
      metaPixel: { id: "123456789012345" },
    },
  },
});

It loads after the app mounted and the first idle callback. List metaPixel in scripts.bundle and the build serves the file from your origin with a SHA-384 integrity (see Bundling). The script sends its own requests to the vendor.

Every key is checked when the config loads and again in useScriptMetaPixel: a wrong value stops the build with a message that starts with scripts.registry.metaPixel. The registry list is on the registry page, and the shared options are in Scripts.