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 onAuthenticateon
Authenticateon Authenticate () => Promise<{ discount: LeadCaptureDiscount; }>() => Promise<{ discount: LeadCaptureDiscount; }> Fired during the discount flow to retrieve the discount to offer.
- Anchor to onBeforeAuthenticateon
Before Authenticateon Before Authenticate () => void | Promise<void>() => void | Promise<void> Fired before authentication begins. Can be async.
- Anchor to onCompleteon
Completeon Complete (event: LeadCaptureCompleteEvent) => void(event: LeadCaptureCompleteEvent) => void Fired when the lead capture flow completes successfully.
- Anchor to onConfirmSuccesson
Confirm Successon Confirm Success () => void() => void Fired after the user confirms a successful action.
- Anchor to onErroron
Erroron Error (event: LeadCaptureErrorEvent) => void(event: LeadCaptureErrorEvent) => void Fired when an error occurs during the flow.
- Anchor to onGetEmailInputon
Get Email Inputon Get Email Input () => HTMLInputElement() => HTMLInputElement Fired to retrieve the email input element (alternative to emailInputSelector).
- Anchor to onLoadon
Loadon Load (event: LeadCaptureLoadEvent) => void(event: LeadCaptureLoadEvent) => void Fired when the component loads and user recognition completes.
- Anchor to onReadyon
Readyon Ready (event: ReadyEvent) => void(event: ReadyEvent) => void SDK-level ready handler (fires when the element's loader resolves).
- Anchor to onRestarton
Restarton Restart () => 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 notifyEmailFieldShownnotify
Email Field Shownnotify Email Field Shown () => void() => voidrequiredrequired Notify the component that the email field has been shown.
- Anchor to onAuthenticateon
Authenticateon Authenticate (handler: () => Promise<{ discount: LeadCaptureDiscount; }>) => void(handler: () => Promise<{ discount: LeadCaptureDiscount; }>) => voidrequiredrequired Register an
handler.- Anchor to onBeforeAuthenticateon
Before Authenticateon Before Authenticate (handler: () => void | Promise<void>) => void(handler: () => void | Promise<void>) => voidrequiredrequired Register an
handler.- Anchor to onCompleteon
Completeon Complete (handler: (event: LeadCaptureCompleteEvent) => void) => void(handler: (event: LeadCaptureCompleteEvent) => void) => voidrequiredrequired Register an
handler.- Anchor to onConfirmSuccesson
Confirm Successon Confirm Success (handler: () => void) => void(handler: () => void) => voidrequiredrequired Register an
handler.- Anchor to onErroron
Erroron Error (handler: (event: LeadCaptureErrorEvent) => void) => void(handler: (event: LeadCaptureErrorEvent) => void) => voidrequiredrequired Register an
handler.- Anchor to onLoadon
Loadon Load (handler: (event: LeadCaptureLoadEvent) => void) => void(handler: (event: LeadCaptureLoadEvent) => void) => voidrequiredrequired Register an
handler.- Anchor to onReadyon
Readyon Ready (handler: (event: ReadyEvent) => void) => void(handler: (event: ReadyEvent) => void) => voidrequiredrequired Register an
handler. Fires immediately if already ready.- Anchor to onRestarton
Restarton Restart (handler: () => void) => void(handler: () => void) => voidrequiredrequired Register an
handler.- Anchor to setAttributeset
Attributeset Attribute (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 signedInsigned
Insigned In booleanbooleanrequiredrequired Whether the user signed in during the flow (as opposed to only providing their email).
- Anchor to consentedScopesconsented
Scopesconsented Scopes stringstring A space-separated list of OAuth scopes the user consented to.
- Anchor to customerAccessTokencustomer
Access Tokencustomer Access Token stringstring A customer access token issued after authentication, if available.
- Anchor to customerAccessTokenExpiresAtcustomer
Access Token Expires Atcustomer Access Token Expires At stringstring ISO 8601 timestamp of when the customer access token expires.
- Anchor to customerUpdateErrorscustomer
Update Errorscustomer Update Errors stringstring Error messages from the customer update mutation, if any.
- Anchor to disclosureAgreeddisclosure
Agreeddisclosure Agreed booleanboolean Whether the user agreed to the disclosure presented during the flow.
- Anchor to emailVerifiedemail
Verifiedemail Verified booleanboolean Whether the user's email has been verified.
- booleanboolean
Whether the user consented to share their phone number.
- Anchor to shopConsentTokenshop
Consent Tokenshop Consent Token stringstring 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 userFounduser
Founduser Found booleanbooleanrequiredrequired Whether a recognized Shop user was detected for the current browser session.