/** * Appends this visitor's Clakta session to a Cakto checkout URL, so the sale it * produces can be attributed to them. Non-checkout URLs, and an `sck` you set * yourself, are returned untouched. * * Called automatically when a visitor clicks a Cakto link on your page — you * only need this for a URL you build yourself, e.g. one you redirect to from * your own server or render into a framework's router link. * * @param url - The Cakto checkout URL. * @returns The URL, decorated when there was something to add. * @example * window.location.href = clakta.decorateCaktoUrl( * "https://pay.cakto.com.br/AA58c2n", * ) */ declare function decorateCaktoUrl(url: string): string; /** * Updates the visitor's consent at runtime (exposed as `clakta.consent.update`) * — call it with the visitor's answer to your cookie banner. * * The answer is remembered — in a cookie for a year, and in localStorage with * no expiry — so later pages apply it from their first event without waiting * for the banner to repeat it. Granting consent * mid-visit starts an identified session from the current page, keeping the * ad parameters the visit arrived with. Revoking it immediately clears every * stored identifier, and later events are recorded anonymously. * * @param enabled - `true` to grant consent, `false` to revoke it. * @example * clakta.consent.update(true) */ declare function updateConsent(enabled: boolean): void; /** * A product involved in an ecommerce event. The fields below are recognised by * Clakta; any extra fields you include are kept as metadata, so you can pass the * shape your platform already uses. */ interface ClaktaProduct { /** Product identifier in your own system (e.g. your database primary key). */ id?: string | number; /** The product name. */ name?: string; /** The unit price in float number format. * * - Example: `100.00` */ price?: number; /** The quantity involved in the action. */ quantity?: number; /** ISO 4217 currency code. On a cart or order line item you can leave this * off — the cart/order level `currency` applies. * * - Example: `"USD"` */ currency?: string; [field: string]: unknown; } /** * The payment methods the Clakta Orders API accepts. * * @see https://www.clakta.com/docs/api-reference/orders/create-order */ type ClaktaPaymentMethod = "credit_card" | "debit_card" | "pix" | "boleto" | "paypal" | "apple_pay" | "google_pay" | "samsung_pay" | "stripe_link"; /** * The customer identifiers carried on a checkout or purchase event — enough to * match the browser event to the order your server sends to the Orders API, and * no more. * * Sent only under `full_attribution` with consent granted; in * `privacy_friendly` mode (or when consent is withheld) the customer block is * dropped from the payload entirely, the same way `identify` is a no-op there. */ interface ClaktaOrderCustomer { /** The customer's email address. */ email?: string; /** The customer's phone number (E.164 format). * * - Example: `+1234567890` */ phone?: string; /** The customer's full name. */ name?: string; [field: string]: unknown; } /** * The attribution parameters carried on a checkout or purchase event. Mirrors * the `tracking` block your server sends to the * [Orders API](https://www.clakta.com/docs/api-reference/orders/create-order), * so both sides describe the click the same way. * * Every field is optional, and an order sent without any of them is simply * recorded as unattributed. `clkt` is the one the SDK can recover on its own: * leave it out and it is read from the current URL, falling back to the URL the * visit landed on. Any extra fields you include are kept as metadata. */ interface ClaktaTrackingParams { /** The Clakta click token — the `clkt` query parameter on your ad's * destination URL. Resolved from the URL when omitted. * * - Example: `"meta:facebook:123456:987654:555555"` */ clkt?: string; /** The `utm_source` the visit arrived with. * * - Example: `"facebook"` */ utm_source?: string; /** The `utm_medium` the visit arrived with. * * - Example: `"cpc"` */ utm_medium?: string; /** The `utm_campaign` the visit arrived with. * * - Example: `"summer-sale"` */ utm_campaign?: string; /** The `utm_content` the visit arrived with. * * - Example: `"video-a"` */ utm_content?: string; [field: string]: unknown; } /** * The order fields carried on a client-side checkout or purchase event. * * This is deliberately a small subset of the * [Orders API](https://www.clakta.com/docs/api-reference/orders/create-order) * payload: only what identifies the order your server sends to `POST /v1/orders`, * which stays the source of truth for its status, totals and contents. The * fields the server owns — `projectId`, `platform`, `status`, timestamps — are * deliberately absent here. * * `orderId` is required, and is the key the two sides are reconciled on: pass * the same id your server sends to the Orders API. Any extra fields you include * are kept as metadata. */ interface ClaktaOrderDetails { /** * **Required.** The order id in your own system (e.g. your database primary * key) — the same value your server sends to the Orders API as `orderId`. */ orderId: string | number; /** The total price in float number format. * * - Example: `100.00` */ totalPrice?: number; /** ISO 4217 currency code. Defaults to the project currency. * * - Example: `"USD"` */ currency?: string; /** How the order is being paid for. */ paymentMethod?: ClaktaPaymentMethod; /** The line items in the order. */ products?: ClaktaProduct[]; /** Identifiers for the customer placing the order. */ customer?: ClaktaOrderCustomer; /** * The attribution parameters the order should be credited to (`clkt` and the * UTMs). Optional — omit `clkt` and the SDK resolves it from the URL. */ tracking?: ClaktaTrackingParams; [field: string]: unknown; } /** * The cart fields carried on an add-to-cart event. No `orderId` — the order * doesn't exist yet at this point in the funnel. Any extra fields you include * are kept as metadata. */ interface ClaktaCartDetails { /** The items being added to the cart. */ products?: ClaktaProduct[]; /** The total price of the items added, in float number format. * * - Example: `100.00` */ totalPrice?: number; /** ISO 4217 currency code. Defaults to the project currency. * * - Example: `"USD"` */ currency?: string; [field: string]: unknown; } /** * Records a product (PDP) view. * * @param product - The product being viewed. * @example * clakta.pageViewWithProduct({ id: "42", name: "Tee", price: 29.99 }) */ declare function pageViewWithProduct(product: ClaktaProduct): void; /** * Records an add-to-cart action. * * No order id here — the order doesn't exist yet at this point in the funnel. * Pass the items added; {@link initiateCheckout} and {@link purchase} pick the * funnel up once your system has created an order. * * @param cart - The items added, plus optional `totalPrice` and `currency`. * @example * clakta.addToCart({ * products: [{ id: "42", name: "Tee", price: 29.99, quantity: 2 }], * totalPrice: 59.98, * currency: "USD", * }) */ declare function addToCart(cart: ClaktaCartDetails): void; /** * Records that checkout has started for an order. * * Requires the `orderId` from your own system — the same id your server sends * to the [Orders API](https://www.clakta.com/docs/api-reference/orders/create-order). * Everything else is a small identifying subset of that payload; the order the * server posts stays the source of truth for status, totals and contents. * * Customer details are sent only under `full_attribution` with consent granted. * * Pass `tracking` to credit the order to a click: `clkt` plus the UTMs. Leave * `clkt` out and the SDK reads it from the current URL, falling back to the URL * the visit landed on — so a checkout page that no longer carries the query * string still attributes. * * @param order - The order being checked out. `orderId` is required. * @example * clakta.initiateCheckout({ * orderId: "1001", * totalPrice: 59.98, * currency: "USD", * products: [{ id: "42", name: "Tee", price: 29.99, quantity: 2 }], * customer: { email: "ada@example.com" }, * // clkt is resolved from the URL when omitted * tracking: { utm_source: "facebook", utm_medium: "cpc" }, * }) */ declare function initiateCheckout(order: ClaktaOrderDetails): void; /** * Records a completed purchase. * * Requires the `orderId` from your own system — the same id your server sends * to the [Orders API](https://www.clakta.com/docs/api-reference/orders/create-order). * This event attributes the purchase to the visitor's session; it never creates * or amends an order. The order your server posts remains the source of truth, * and Clakta reconciles the two on `orderId` — so a visitor who closes the tab * before your thank-you page renders still costs you nothing. * * Customer details are sent only under `full_attribution` with consent granted. * * Pass `tracking` to credit the order to a click: `clkt` plus the UTMs. Leave * `clkt` out and the SDK reads it from the current URL, falling back to the URL * the visit landed on — so a thank-you page that no longer carries the query * string still attributes. * * @param order - The order that was purchased. `orderId` is required. * @example * clakta.purchase({ * orderId: "1001", * totalPrice: 59.98, * currency: "USD", * paymentMethod: "credit_card", * products: [{ id: "42", name: "Tee", price: 29.99, quantity: 2 }], * customer: { email: "ada@example.com" }, * // clkt is resolved from the URL when omitted * tracking: { utm_source: "facebook", utm_medium: "cpc" }, * }) */ declare function purchase(order: ClaktaOrderDetails): void; /** * Event names Clakta labels and describes itself, in the spirit of GA4's * recommended events. Any other name is a custom event. */ declare const STANDARD_EVENTS: readonly ["sign_up", "login", "add_payment_info", "add_to_wishlist"]; type StandardEventName = (typeof STANDARD_EVENTS)[number]; /** Free-form properties sent with an event. Shown in the user's journey. */ type ClaktaEventProperties = Record; interface ClaktaSignUpDetails { /** How the account was created, e.g. `"email"` or `"google"`. */ method?: string; [property: string]: unknown; } interface ClaktaLoginDetails { /** How the visitor logged in, e.g. `"email"` or `"google"`. */ method?: string; [property: string]: unknown; } interface ClaktaPaymentInfoDetails { /** The payment method saved. */ paymentMethod?: ClaktaPaymentMethod | (string & {}); /** The amount being paid, in float number format (e.g. `100.00`). */ value?: number; /** ISO 4217 currency code of `value`. */ currency?: string; [property: string]: unknown; } interface ClaktaWishlistDetails { /** The product added to the wishlist. */ product?: ClaktaProduct; [property: string]: unknown; } /** The properties each standard event is typed with. */ interface ClaktaStandardEventProperties { sign_up: ClaktaSignUpDetails; login: ClaktaLoginDetails; add_payment_info: ClaktaPaymentInfoDetails; add_to_wishlist: ClaktaWishlistDetails; } /** * Records a named event in the current session, the way `gtag("event", …)` or * `fbq("track", …)` do. It shows up in the visitor's journey, can be counted * by the Assistant and can start a workflow. The first time a name is sent, * it is created in your project. * * Use a standard name ({@link STANDARD_EVENTS}) when one fits, so Clakta can * label it, or any name of your own. Names may use letters, numbers, spaces * and `_ . : -`, up to 100 characters. * * @param name - The event name, e.g. `"sign_up"` or `"invited_teammate"`. * @param properties - Optional free-form properties to attach to the event. * @example * clakta.trackEvent("sign_up", { method: "google" }) * clakta.trackEvent("add_to_wishlist", { product: { id: "42", name: "Tee", price: 29.99 } }) * clakta.trackEvent("invited_teammate", { role: "editor" }) */ declare function trackEvent(name: Name, properties?: ClaktaStandardEventProperties[Name]): void; declare function trackEvent(name: string, properties?: ClaktaEventProperties): void; /** * The 1.x form: `trackingId` is the event name, and `eventType` is kept with * the event's properties. * * @deprecated Use `trackEvent(name, properties)`. */ declare function trackEvent(trackingId: string, eventType: string, metadata?: ClaktaEventProperties, triggerMethod?: "automatic" | "manual"): void; /** * Appends this visitor's Clakta session to a Hotmart checkout URL, so the sale it * produces can be attributed to them. Non-checkout URLs, and an `sck` you set * yourself, are returned untouched. * * Called automatically when a visitor clicks a Hotmart link on your page — you * only need this for a URL you build yourself, e.g. one you redirect to from * your own server or render into a framework's router link. * * @param url - The Hotmart checkout or hotlink URL. * @returns The URL, decorated when there was something to add. * @example * window.location.href = clakta.decorateHotmartUrl( * "https://pay.hotmart.com/P12345678X", * ) */ declare function decorateHotmartUrl(url: string): string; /** * The customer fields Clakta understands. At least one identifier — * {@link CustomerData.externalId}, {@link CustomerData.claktaCustomerId} or * {@link CustomerData.email} — is required to attach the session to a customer. * Any extra fields are forwarded as free-form traits. */ interface CustomerData { /** The customer's id in your own system (e.g. your database primary key). */ externalId?: string | number; /** The id of an existing Clakta customer record. * * - Example: `cust_1234567890` */ claktaCustomerId?: string; /** The customer's email address. */ email?: string; /** The customer's full name. */ name?: string; /** The customer's phone number (E.164 format). * * - Example: `+1234567890` */ phone?: string; /** Any additional attributes, forwarded as free-form traits. */ [trait: string]: unknown; } /** * Identifies the visitor in the current session by attaching customer details * to it — call this when you know who the visitor is (e.g. on login or signup). * Requires at least one identifier: `externalId`, `claktaCustomerId` or `email`. * * Identifying a visitor is the opposite of anonymous collection, so this is a * no-op for `privacy_friendly` sources (and when the visitor has withheld * consent) — nothing is sent and nothing is stored. If it runs before init's * config has resolved, the call is buffered and replayed once the tracking mode * is known (and dropped if the config can't be resolved at all). * * @param data - The customer identifiers and any extra traits to attach. * @example * clakta.identify({ externalId: "user_123", email: "ada@example.com", name: "Ada Lovelace" }) */ declare function identify(data: CustomerData): void; /** * Auto-init: initializes from the loading `