Skip to content
Attribute Hosted Checkouts

Attribute Hosted Checkouts

Availability: Conversion tracking is available on Professional and Agency plans.

A connected Dodo Payments or Stripe connector records sales from the provider’s webhooks (see provider connectors to connect one). A sale is attributed to a Shortn link only when the payment carries the click id. Where Shortn can hand it over by itself, it does; where it can’t, pass it in your checkout code.

A Dodo Payments or Stripe connector belongs to the workspace you connect it in, for good: its workspace can’t be changed later. To send an account’s sales to another workspace, disconnect the connector, then connect the account again in that workspace (with the new webhook address and signing secret it shows). Shopify connectors are the exception: one store’s connector can serve several workspaces, and you can change which.

How the customer reaches the checkoutWhat carries the click idWhat you do
A Shortn link that points straight at a checkout linkThe Shortn redirectNothing
A checkout link on your site (<a href>)The capture script, when the link is followedInstall the capture script
Your JavaScript opens the checkout URLshortn.conversion.checkoutURL()Wrap the URL
Your server creates the checkoutCheckout metadataPass the click id to your server and set it in metadata
An embedded or overlay checkoutCheckout optionsPass the click id when you open it

Where the click id goes

ProviderCheckout link parameterMetadata key
Dodo Paymentsmetadata_snt_click_idsnt_click_id
Stripe Payment Linksclient_reference_idsnt_click_id

Dodo Payments copies metadata_* parameters from a checkout link into the payment’s metadata. Stripe keeps a Payment Link’s client_reference_id on the Checkout Session. Shortn never replaces a value you already set.

Links straight to a checkout

When a Shortn link’s destination is a Dodo Payments checkout link (checkout.dodopayments.com/buy/...) or a Stripe Payment Link (buy.stripe.com/...), the redirect adds the click id to the parameter above. No code is needed.

Such a link always credits the click that brought the buyer to the checkout, even when the link’s model is first touch: first touch needs the capture script on your own site, where it can remember a visitor’s earlier clicks.

Checkout links on your site

With the capture script installed, a visitor who follows a Dodo Payments checkout link or a Stripe Payment Link on your site carries the stored click id into the checkout. The script adds the parameter at the moment the link is followed, including links rendered after the page loads. It changes nothing when tracking consent is missing, when no click id is stored, or when the link already has the parameter.

Add data-shortn-ignore="true" to a link to leave it unchanged, or turn the behavior off for the whole site with data-checkout-links="false" on the script tag.

Checkouts opened from JavaScript

Wrap the checkout URL before you navigate to it:

const url = "https://checkout.dodopayments.com/buy/pdt_123?quantity=1";
window.location.href = window.shortn.conversion.checkoutURL(url);

checkoutURL() returns the URL unchanged when it isn’t a supported checkout link or no click id is available, so it is safe to call on every checkout.

Checkouts created on your server

Send the click id from the browser with the checkout request. With data-form-enrichment="true", forms already include a hidden shortn_click_id field; otherwise read window.shortn.conversion.getClickId(). Then set it in the checkout’s metadata.

Dodo Payments:

const session = await dodo.checkoutSessions.create({
  product_cart: [{ product_id: "pdt_123", quantity: 1 }],
  metadata: { snt_click_id: clickId },
});

Stripe:

const session = await stripe.checkout.sessions.create({
  mode: "payment",
  line_items: [{ price: "price_123", quantity: 1 }],
  success_url: "https://example.com/thanks",
  metadata: { snt_click_id: clickId },
});

Skip the field when the click id is empty.

What a buyer can change

A checkout link’s parameters are in the buyer’s address bar, so the buyer can change them before paying. On a Stripe Payment Link or a Dodo Payments checkout link, a buyer can remove the click id, and the sale is not attributed. They can also replace it with another click id they got by following one of your Shortn links, and that link gets the credit. In practice the buyer picks which of your links gets credit, much like choosing whose referral code to use.

What a buyer can’t do:

  • Use a click from another workspace. Shortn only accepts clicks on the links of the connector’s own workspace.
  • Make up a click id. Each one is random and must match a click Shortn recorded.
  • Keep an old click earning forever. A click only credits sales within its attribution window.

When the credit must not be changeable, for example when partners are paid commissions on these sales, create the checkout on your server and set snt_click_id in its metadata (Checkouts created on your server). Buyers can’t change the metadata your server sets. On Stripe, Shortn reads it before client_reference_id. Commissions also wait for your approval before they can be paid, so you can review unusual sales first.

Embedded and overlay checkouts

Pass the click id in the checkout’s options when you open it, using the metadata key above. For a Stripe Pricing Table, set the client-reference-id attribute:

<stripe-pricing-table
  pricing-table-id="prctbl_123"
  publishable-key="pk_test_123"
  client-reference-id="">
</stripe-pricing-table>
<script>
  const table = document.querySelector("stripe-pricing-table");
  const clickId = window.shortn.conversion.getClickId();
  if (clickId) table.setAttribute("client-reference-id", clickId);
</script>

Currencies

Sales are recorded in the currency the provider reports, before tax:

  • Stripe: the currency of your prices. With Adaptive Pricing the customer may pay in their own currency, but Stripe still reports your price and currency, so that is what Shortn records.
  • Dodo Payments: the currency the customer paid in. When Dodo credits your balance in another currency (adaptive pricing), Shortn also keeps that settlement amount, and uses it for totals in that currency.

Totals across currencies are shown in your reporting currency; see Reporting Currency.

Check the result

Open Conversions → Setup → Event log, or choose View this connector’s events in the Event log on the connector. A payment without a click id shows as Ignored with “Provider sale has no Shortn click attribution”; an attributed payment shows as Processed. See event log.

Last updated on