API Reference

You can customize and configure Metricalp script behaviours with providing a few data attributes. If you are using integration libraries like for React and NextJS, you can provide these settings platform specific way (as component props for React) so please check your platform specific integration docs. All configurations will match 1-to-1, so you can check this documentation for explanations.If you are using pure script embed, you can provide below settings with data attributes. All data attributes are optional except data-tid.

data-tid

RequiredType: stringDefault value: -

This is your tid a.k.a tracker id. You can get info about to getting it from Tracker Settings / Embed & Share. You need to provide this attribute to make Metricalp work.

data-allow-localhost

OptionalType: "true" or "false" strings because HTML attributes only accept string valuesDefault value: "false"

If you are integrating Metricalp in your localhost for testing purposes, you can set this attribute to "true". Otherwise Metricalp will not collect events in localhost to save your usage quota. Check this docs for detailed info If you are allowing specific hostnames in your tracker settings, please also add localhost to allowed hostnames.

data-custom-event-endpoint

OptionalType: stringDefault value: "https://event.metricalp.com"

If you proxied Metricalp event endpoint to prevent adblockers, use this attribute to provide proxied endpoint. Check this docs for detailed info.

data-disable-auto-route-catch

OptionalType: "true" or "false" strings because HTML attributes only accept string valuesDefault value: "false"

Defaultly Metricalp listens for window.history events to catch route changes in JS applications. You can disable it with setting this attribute to true, then you can track routes manually.

data-hash-routing

OptionalType: "true" or "false" strings because HTML attributes only accept string valuesDefault value: "false"

If your application uses hash routing (example.com/#about, example.com/#homepage), you can set this attribute to true. Then Metricalp will listen for hash route changes.

data-disable-custom-elm-events

OptionalType: "true" or "false" strings because HTML attributes only accept string valuesDefault value: "false"

Metricalp defaultly supports HTML attribute based custom event tracking. Like <button data-metricalp-event="follow click" data-metricalp-user="John">Click</button>, this button click will create a custom event with name "follow click" and custom prop "user" with value "John". You can disable this feature with setting this attribute to true. Check this docs for detailed info