Free plan · No credit card · Set up in 5 minutes

The script is about 11 KB, loads asynchronously and never slows your pages down. Install it once per website, on every page. Your site key is on the website's 1. Install tab.

Option 1: paste the code

Add this line to every page, inside <head>, then publish your site.

HTML
<script async src="https://cdn.sourcexray.com/sx.js" data-site="sx_your_site_key"></script>

Option 2: Google Tag Manager

  1. In Tag Manager, create a new tag of the type Custom HTML and paste the code below.
  2. Set the trigger to All Pages (Initialization or Page View).
  3. Click Submit, then Publish.
Custom HTML tag
<script>
  window.sxConfig = { site: 'sx_your_site_key' };
</script>
<script async src="https://cdn.sourcexray.com/sx.js"></script>

Option 3: WordPress plugin

The plugin adds the script for you and puts the lead source into your form notification emails. See WordPress plugin.

Website builders

BuilderWhere to paste the code
WebflowSite settings, Custom code, Head code. Then publish.
ShopifyOnline Store, Themes, Edit code, layout/theme.liquid, just before </head>.
SquarespaceSettings, Advanced (or Developer tools), Code Injection, Header. Available on plans that include code injection.
WixSettings, Custom code, Add custom code. Place it in Head and load it on all pages. Needs a premium plan with a connected domain.
FramerSite settings, General, Custom code, End of <head> tag.
Anything elseWherever the builder lets you add code to the head of every page.

Optional settings

Add these attributes to the script tag. With Google Tag Manager, put them in window.sxConfig instead, for example window.sxConfig = { site: 'sx_your_site_key', consent: 'wait' };

AttributesxConfig keyWhat it does
data-consent="wait"consentStores nothing until the visitor consents. See Privacy, cookies and consent.
data-pii="off"piiNever sends names, emails or phone numbers. Leads arrive with their source only.
data-auto-fields="off"autoFieldsStops the source fields being added to plain HTML, Webflow and Shopify forms automatically.
data-datalayer="off"datalayerStops the sx_lead event being pushed to the Google Tag Manager dataLayer.
data-ignore-referrers="pay.example.com"ignoreReferrersDomains that never count as a new source, such as payment pages or booking tools. Separate with commas.
data-cookie-domain=".example.com"cookieDomainShares the visitor's source across your subdomains.

To skip a single form, add data-sx-no-auto to its <form> tag.

Check it is working

Open any page with ?sx_debug=1 on the end of the address and open the browser console. SourceXray logs what it recorded, which forms it found and each lead it sent.

Still need help?

Email info@sourcexray.com with your website address and what you tried.