Skip to content

Write an adapter ​

An adapter sends the events of a vendor tool on your page, for example a chat or a form tool. Use this page when QuickPipe has no adapter for your tool. For a cookie banner, refer to Write a consent adapter.

Built-in adapters ​

The script loads these adapters automatically when the vendor is on the page:

AdapterExample events
HubSpot forms in a framehubspot.form_submitted
Typeformtypeform.form_submitted
Calendlycalendly.event_scheduled
Cal.comcalcom.booking_created
Pipedrivepipedrive.form_submitted
Intercomintercom.conversation_started
Cookiebot, CookieYes, OneTrustConsent only

A form that the page shows needs no adapter: the core sends form.submitted for it. Refer to Capture forms for the forms in a frame.

The core loads the file of an adapter only when its vendor is on the page. The browser checks the SRI hash of the file. An adapter identifies a person only from values that the vendor gives.

Procedure ​

  1. Write an object of the type Adapter:

    ts
    import type { Adapter } from '@quickpipeaiab/lead-scoring/adapters';
    
    export const quoteTool: Adapter = {
      name: 'quotetool',
      detect: (win) => 'QuoteTool' in win,
      start(ctx) {
        const onQuote = (event: Event) => {
          const { email, total } = (event as CustomEvent<{ email: string; total: number }>).detail;
          ctx.identify({ email });
          ctx.track('quotetool.quote_created', { total });
        };
        window.addEventListener('quotetool:quote', onQuote);
        return () => window.removeEventListener('quotetool:quote', onQuote);
      },
    };
  2. Add the adapter to the client:

    ts
    lg.use(quoteTool);

Result ​

The client calls detect. When detect returns true, the client calls start. The client calls the returned function when it stops.

The Context ​

MemberFunction
trackSends an event. Use the name form {vendor}.{action}.
identifyAdds identifiers to the visitor
accountLinks the visitor to a company
setSets attributes of the visitor
consentSets the consent state of a purpose. Only a consent adapter calls it.
configThe values of the data-<adapter name>-* attributes of the script tag
logWrites a message in debug mode

Stop adapters ​

  • To stop all adapters, set data-adapters="off" on the script tag.
  • To stop some adapters, set a list with a minus sign before each name, for example data-adapters="-typeform,-intercom".