Skip to main content
Use these functions in your own JavaScript to connect buttons, read visit data or send events. For an ordinary offer link, follow Connect an offer button. Install the tracking snippet before using these functions. See Install the tracking script. On Hosted landings, publish with Add Direct Tracking enabled.

Call a function

Put your code inside metricanicCallback:
Place your code after the tracking snippet. Your code runs when tracking is ready.

Functions

Connect buttons added later

When the page loads, the script connects links to https://<tracking domain>/click and elements with data-dtp-link, including buttons. After a popup, quiz or page builder adds buttons, call:
Call it again after each change.

Build your own offer button

Use this when a button needs its own logic before opening the offer:
Call registerClick() once per click. Do not use it on links the script already connects. They record clicks automatically.

Pass the click ID to a form

Save the click ID with the lead so your CRM can send events for this visit later:
Your CRM sends the event to the incoming event URL with this click ID.

Send an event

  • Configure the Event ID in the campaign’s 2. Events tab. See Decide what counts as a conversion.
  • Without txuid, every call adds a new event. Use a fixed txuid for steps that must count once, such as 'form-open'.
  • Visitors can see and change browser requests. Send revenue from your server or affiliate network instead.
  • Check the result in Events.

Handle a failed start

Use onError if your page needs to respond when tracking cannot start: