lead-capture
The lead-capture feature enables merchants to capture leads on their storefront by recognizing returning Shop users and facilitating email collection.
It supports two main flows:
- Discount flow: Offer a discount code in exchange for an email, using the
onAuthenticatecallback. - Default flow: Standard email capture without a discount incentive.
The feature detects whether the current visitor is a known Shop user and can display a call-to-action button (for example, "Continue with Shop") or integrate inline with an existing email input field.
Anchor to UsageUsage
Create a lead-capture instance via the SDK:
You can also eagerly preload the feature loader before calling create:
Anchor to leadcaptureconfigLeadCaptureConfig
Config accepted by sdk.create('lead-capture', config).
Derived from : includes all component attributes, all event handlers, plus SDK-specific fields like appearance.
- Anchor to appearanceappearanceappearanceAppearanceConfigAppearanceConfig
Component-level appearance overrides. Variables set here take precedence over those set in
initializeorupdate().- Anchor to attributesattributesattributesLeadCaptureAttributesLeadCaptureAttributes
Component attributes. These map to HTML attributes on the underlying
<shop-lead-capture>element.- Anchor to onAuthenticateonAuthenticateonAuthenticate() => Promise<{ discount: LeadCaptureDiscount; }>() => Promise<{ discount: LeadCaptureDiscount; }>
Fired during the discount flow to retrieve the discount to offer.
- Anchor to onBeforeAuthenticateonBeforeAuthenticateonBeforeAuthenticate() => void | Promise<void>() => void | Promise<void>
Fired before authentication begins. Can be async.
- Anchor to onCompleteonCompleteonComplete(event: LeadCaptureCompleteEvent) => void(event: LeadCaptureCompleteEvent) => void
Fired when the lead capture flow completes successfully.
- Anchor to onConfirmSuccessonConfirmSuccessonConfirmSuccess() => void() => void
Fired after the user confirms a successful action.
- Anchor to onErroronErroronError(event: LeadCaptureErrorEvent) => void(event: LeadCaptureErrorEvent) => void
Fired when an error occurs during the flow.
- Anchor to onGetEmailInputonGetEmailInputonGetEmailInput() => HTMLInputElement() => HTMLInputElement
Fired to retrieve the email input element (alternative to emailInputSelector).
- Anchor to onLoadonLoadonLoad(event: LeadCaptureLoadEvent) => void(event: LeadCaptureLoadEvent) => void
Fired when the component loads and user recognition completes.
- Anchor to onReadyonReadyonReady(event: ReadyEvent) => void(event: ReadyEvent) => void
SDK-level ready handler (fires when the element's loader resolves).
- Anchor to onRestartonRestartonRestart() => void() => void
Fired when the user restarts the flow.
AppearanceConfig
Appearance configuration for styling Shop SDK components. Set at the instance level in `initialize()` or per-feature in `create()`.
- preferredLoginExperience
Preferred UX for the login experience: `'redirect'`, `'popup'`, or `null` for the default.
'redirect' | 'popup' | null - variables
CSS custom property overrides.
AppearanceVariables
AppearanceVariables
CSS custom properties that control styling of Shop SDK components. All properties are optional — only set ones will be applied.
- --buttons-radius
Border radius for buttons (e.g. `'12px'`).
string - --font-paragraph--line-height
Line height for paragraph text (e.g. `'22px'`).
string - --font-paragraph--size
Font size for paragraph text (e.g. `'16px'`).
string - --shop-pay-button-border-radius
Border radius of the Shop Pay button (e.g. `'4px'`, `'999px'`).
string - --shop-pay-button-height
Height of the Shop Pay button (e.g. `'48px'`).
string - --shop-pay-button-width
Width of the Shop Pay button (e.g. `'260px'`, `'100%'`).
string - --x-spacing-base
Base spacing unit (e.g. `'14px'`).
string - [variable: `--${string}`]
string | undefined
LeadCaptureAttributes
Attributes accepted by the `lead-capture` feature.
- apiKey
Secondary client ID. If supplied, the client ID will receive a delegated consent token on behalf of the primary client ID.
string - buttonLayout
Layout style for the button: `'or'` or `'standalone'`.
LeadCaptureButtonLayout - buttonType
Type of CTA button shown when a Shop user is recognized.
LeadCaptureButtonType - clientId
Primary Client ID. This client will be shown to the buyer in the sign in flow and is the Relying Party of the OAuth flow. If omitted, defaults to the Shopify Merchant.
string - devMode
Enable development mode for testing.
boolean - disclosureScope
Additional disclosure scopes requiring explicit consent.
string - disclosureText
Custom disclosure text shown during the consent step.
string - disclosureTitle
Custom title for the disclosure consent screen.
string - emailInputSelector
CSS selector for the email input on the page.
string - phoneCapture
Enable phone number capture.
boolean - phoneCaptureDisclosureText
Disclosure text shown when requesting the user's phone number.
string - scope
Space-separated list of OAuth scopes.
string - storefrontOrigin
Origin of the embedding storefront.
string - uxMode
UX mode for the auth flow: `'iframe'`, `'windoid'`, or `'redirect'`.
'iframe' | 'windoid' | 'redirect'
LeadCaptureButtonLayout
Layout style for the lead capture button. - `'or'` — Shows an “or” separator between the button and the form. - `'standalone'` — Shows the button without any separator.
'or' | 'standalone'LeadCaptureButtonType
The type of call-to-action button shown when a Shop user is recognized. - `'none'` — No button; uses inline email-based flow instead. - `'claim'` — Shows “Claim with Shop” button. - `'continue'` — Shows “Continue with Shop” button. - `'favorite'` — Shows “Favorite with Shop” button. - `'notify'` — Shows “Notify me with Shop” button. - `'save'` — Shows “Save with Shop” button.
'none' | 'claim' | 'continue' | 'favorite' | 'notify' | 'save'LeadCaptureDiscount
A discount to apply after successful lead capture.
- code
The discount code string.
string - gid
The Shopify global ID of the discount, if available.
string
LeadCaptureCompleteEvent
Event payload dispatched when the lead capture flow completes successfully.
- consentedScopes
A space-separated list of OAuth scopes the user consented to.
string - customerAccessToken
A customer access token issued after authentication, if available.
string - customerAccessTokenExpiresAt
ISO 8601 timestamp of when the customer access token expires.
string - customerUpdateErrors
Error messages from the customer update mutation, if any.
string - disclosureAgreed
Whether the user agreed to the disclosure presented during the flow.
boolean - email
The email address captured from the user.
string - emailVerified
Whether the user's email has been verified.
boolean - phoneShareConsent
Whether the user consented to share their phone number.
boolean - shopConsentToken
A token that can be exchanged in the Shop Partners API to receive access for a user in the Shop Users API
string - signedIn
Whether the user signed in during the flow (as opposed to only providing their email).
boolean
LeadCaptureErrorEvent
Event payload dispatched when an error occurs during lead capture.
- code
A machine-readable error code.
string - email
The email address associated with the error, if available.
string - message
A human-readable error message.
string
LeadCaptureLoadEvent
Event payload dispatched when the lead capture component finishes loading.
- userFound
Whether a recognized Shop user was detected for the current browser session.
boolean
ReadyEvent
Event payload passed to the `onReady` handler when a feature element finishes loading.
- detail
Underlying `CustomEvent.detail` from the element's `'loaded'` event, when available. Shape is feature-specific — e.g. for lead-capture this includes fields like `userFound`, `loginTitle`, etc. emitted by `useAuthorizeEventListener`.
unknown - elementTagName
Tag name of the element that became ready, e.g. `shop-lead-capture`.
string
Anchor to leadcaptureinstanceLeadCaptureInstance
Runtime instance returned by sdk.create('lead-capture').
Exposes:
- All component methods from the registration spec
for updating attributes after creation- Event subscription methods for each event handler
with late-subscriber semanticselementfor DOM insertiondestroyfor cleanup
- Anchor to destroydestroydestroy() => void() => voidrequiredrequired
Tear down listeners and remove the element from the DOM if attached.
- Anchor to elementelementelementHTMLElementHTMLElementrequiredrequired
The underlying custom element. The consumer is responsible for inserting it into the DOM.
- Anchor to notifyEmailFieldShownnotifyEmailFieldShownnotifyEmailFieldShown() => void() => voidrequiredrequired
Notify the component that the email field has been shown.
- Anchor to onAuthenticateonAuthenticateonAuthenticate(handler: () => Promise<{ discount: LeadCaptureDiscount; }>) => void(handler: () => Promise<{ discount: LeadCaptureDiscount; }>) => voidrequiredrequired
Register an
handler.- Anchor to onBeforeAuthenticateonBeforeAuthenticateonBeforeAuthenticate(handler: () => void | Promise<void>) => void(handler: () => void | Promise<void>) => voidrequiredrequired
Register an
handler.- Anchor to onCompleteonCompleteonComplete(handler: (event: LeadCaptureCompleteEvent) => void) => void(handler: (event: LeadCaptureCompleteEvent) => void) => voidrequiredrequired
Register an
handler.- Anchor to onConfirmSuccessonConfirmSuccessonConfirmSuccess(handler: () => void) => void(handler: () => void) => voidrequiredrequired
Register an
handler.- Anchor to onErroronErroronError(handler: (event: LeadCaptureErrorEvent) => void) => void(handler: (event: LeadCaptureErrorEvent) => void) => voidrequiredrequired
Register an
handler.- Anchor to onLoadonLoadonLoad(handler: (event: LeadCaptureLoadEvent) => void) => void(handler: (event: LeadCaptureLoadEvent) => void) => voidrequiredrequired
Register an
handler.- Anchor to onReadyonReadyonReady(handler: (event: ReadyEvent) => void) => void(handler: (event: ReadyEvent) => void) => voidrequiredrequired
Register an
handler. Fires immediately if already ready.- Anchor to onRestartonRestartonRestart(handler: () => void) => void(handler: () => void) => voidrequiredrequired
Register an
handler.- Anchor to setAttributesetAttributesetAttribute(attrs: Partial<LeadCaptureAttributes>) => void(attrs: Partial<LeadCaptureAttributes>) => voidrequiredrequired
Update one or more attributes on the underlying element. Accepts the same attribute keys as
config.attributes.- Anchor to startstartstart(email?: string) => void(email?: string) => voidrequiredrequired
Trigger the lead-capture flow, optionally with a pre-filled email.
Anchor to leadcapturecompleteeventLeadCaptureCompleteEvent
Event payload dispatched when the lead capture flow completes successfully.
- Anchor to emailemailemailstringstringrequiredrequired
The email address captured from the user.
- Anchor to signedInsignedInsignedInbooleanbooleanrequiredrequired
Whether the user signed in during the flow (as opposed to only providing their email).
- Anchor to consentedScopesconsentedScopesconsentedScopesstringstring
A space-separated list of OAuth scopes the user consented to.
- Anchor to customerAccessTokencustomerAccessTokencustomerAccessTokenstringstring
A customer access token issued after authentication, if available.
- Anchor to customerAccessTokenExpiresAtcustomerAccessTokenExpiresAtcustomerAccessTokenExpiresAtstringstring
ISO 8601 timestamp of when the customer access token expires.
- Anchor to customerUpdateErrorscustomerUpdateErrorscustomerUpdateErrorsstringstring
Error messages from the customer update mutation, if any.
- Anchor to disclosureAgreeddisclosureAgreeddisclosureAgreedbooleanboolean
Whether the user agreed to the disclosure presented during the flow.
- Anchor to emailVerifiedemailVerifiedemailVerifiedbooleanboolean
Whether the user's email has been verified.
- booleanboolean
Whether the user consented to share their phone number.
- Anchor to shopConsentTokenshopConsentTokenshopConsentTokenstringstring
A token that can be exchanged in the Shop Partners API to receive access for a user in the Shop Users API
Anchor to leadcaptureerroreventLeadCaptureErrorEvent
Event payload dispatched when an error occurs during lead capture.
- Anchor to codecodecodestringstringrequiredrequired
A machine-readable error code.
- Anchor to messagemessagemessagestringstringrequiredrequired
A human-readable error message.
- Anchor to emailemailemailstringstring
The email address associated with the error, if available.
Anchor to leadcaptureloadeventLeadCaptureLoadEvent
Event payload dispatched when the lead capture component finishes loading.
- Anchor to userFounduserFounduserFoundbooleanbooleanrequiredrequired
Whether a recognized Shop user was detected for the current browser session.