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.
<script async src="https://cdn.sourcexray.com/sx.js" data-site="sx_your_site_key"></script>Option 2: Google Tag Manager
- In Tag Manager, create a new tag of the type Custom HTML and paste the code below.
- Set the trigger to All Pages (Initialization or Page View).
- Click Submit, then Publish.
<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
| Builder | Where to paste the code |
|---|---|
| Webflow | Site settings, Custom code, Head code. Then publish. |
| Shopify | Online Store, Themes, Edit code, layout/theme.liquid, just before </head>. |
| Squarespace | Settings, Advanced (or Developer tools), Code Injection, Header. Available on plans that include code injection. |
| Wix | Settings, Custom code, Add custom code. Place it in Head and load it on all pages. Needs a premium plan with a connected domain. |
| Framer | Site settings, General, Custom code, End of <head> tag. |
| Anything else | Wherever 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' };
| Attribute | sxConfig key | What it does |
|---|---|---|
data-consent="wait" | consent | Stores nothing until the visitor consents. See Privacy, cookies and consent. |
data-pii="off" | pii | Never sends names, emails or phone numbers. Leads arrive with their source only. |
data-auto-fields="off" | autoFields | Stops the source fields being added to plain HTML, Webflow and Shopify forms automatically. |
data-datalayer="off" | datalayer | Stops the sx_lead event being pushed to the Google Tag Manager dataLayer. |
data-ignore-referrers="pay.example.com" | ignoreReferrers | Domains that never count as a new source, such as payment pages or booking tools. Separate with commas. |
data-cookie-domain=".example.com" | cookieDomain | Shares 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.
Email info@sourcexray.com with your website address and what you tried.