Thunder Docs
  1. Custom stores integration
  • Custom stores integration
    • Thunder Script Integration
    • Webhooks Integration
    • Orders Webhook
      POST
    • Products Webhook
      POST
  1. Custom stores integration

Thunder Script Integration

Thunder Script#

Thunder Script is a lightweight, asynchronous snippet (typically added in your site’s <head>) that collects visitor, source, and login attribution data in real time. By embedding a small JavaScript file, Thunder can:
Identify visitors across sessions (durable device/user identifier)
Capture landing (first-visit) context: referrer, UTM parameters, and click IDs
Detect and attribute logins (when you provide customer info in localStorage)
Persist key attribution parameters while gracefully handling browser storage limitations
Thunder Script

Table of Contents#

Overview
Quick Start
Customer Identification
Data You Provide
Verification
Event Lifecycle
Browser Storage
Privacy & Compliance
Best Practices
Troubleshooting
FAQ
Implementation Checklist

Overview#

Thunder automatically tracks visitors from their very first page visit until they become customers.
It provides:
Visitor identification
Marketing attribution
Campaign tracking
Login attribution
Cross-session identification
Durable visitor IDs
Customer attribution for reporting
The script is lightweight, loads asynchronously, and has minimal impact on page performance.

Quick Start#

1. Install Thunder Script#

Add the following script inside the <head> of every page.

2. Identify Logged-in Customers#

After a successful login, store the customer information in localStorage under the key user.
That's it.
Thunder will automatically:
Track the landing visit
Capture attribution parameters
Detect the customer login
Associate the customer with their original visitor
Attribute future conversions correctly

Customer Identification#

Thunder initially tracks visitors anonymously.
Once the visitor authenticates, your application should store the customer information inside localStorage.user.
Example:
Thunder automatically detects this object and sends a Login event.
This links the anonymous visitor with the authenticated customer, allowing future purchases and interactions to be correctly attributed.

Field Specifications#

FieldTypeRequiredDescription
idString or NumberYesUnique customer identifier
emailStringRecommendedCustomer email address
mobileStringRecommendedCustomer phone number in international format

Notes#

Email is automatically converted to lowercase.
Phone numbers are automatically normalized.
Customer IDs should remain stable across sessions.

Data You Provide#

Thunder only requires customer information after login.
FieldRequired
idYes
emailRecommended
mobileRecommended
No additional API calls are necessary.

Verification#

Browser Storage#

Open Developer Tools → Application → Local Storage.
Verify that:
user
exists after login.

Browser Support#

Thunder supports all modern browsers.
Chrome
Edge
Firefox
Safari
Mobile Safari
Chrome for Android

Privacy & Compliance#

Depending on your region, you may need to obtain user consent before enabling visitor tracking.
Examples include:
GDPR
CCPA
ePrivacy Directive
If required, initialize Thunder only after consent has been granted.

Customer Data#

If you provide customer email or phone numbers, Thunder will transmit those values for attribution purposes.
If your organization requires it, consider hashing or tokenizing customer identifiers before storing them.

Sensitive Information#

Thunder does not collect:
Credit card numbers
Payment information
Passwords
Authentication tokens

Best Practices#

For the most accurate attribution:
Load Thunder inside <head>.
Store the customer immediately after login.
Use a permanent customer ID.
Keep customer emails consistent.
Use international phone numbers.
Avoid changing customer IDs.

Troubleshooting#

Login Event Not Sent#

Verify that:
localStorage.user exists
The value is valid JSON
The customer ID is present

Attribution Missing#

Check that:
Thunder loads before redirects.
Landing pages contain UTM parameters.
The visitor was tracked before login.

Duplicate Customers#

Always use the same customer ID for the same customer.
Do not generate random IDs.

Script Not Loading#

Verify:
The script is inside <head>
The CDN URL is correct
Browser extensions are not blocking requests

FAQ#

Does Thunder affect page performance?#

No.
Thunder loads asynchronously and has minimal impact on page rendering.

Does Thunder work with Single Page Applications (SPA)?#

Yes.
Thunder supports modern frameworks such as:
Next.js
React
Vue
Angular

Does Thunder require cookies?#

Thunder prefers cookies when available and gracefully falls back to browser storage when necessary.

Can customer information be updated?#

Yes.
Simply overwrite the localStorage.user object.
Thunder automatically detects changes.

What happens if the customer clears cookies?#

Thunder will generate a new visitor identifier.
Future visits will be treated as a new visitor unless another identification event occurs.

Implementation Checklist#

Before going live, verify the following:
Thunder Script installed in head tag
Script loads successfully
Landing events are received
Customer information stored after login
Login events appear
Attribution appears in the Thunder dashboard
Browser storage verified
Privacy requirements reviewed

Next Steps#

Once Thunder Script is installed and customer identification is configured, you're ready to integrate:
Order Attribution API
Products API
Marketing Platform Integrations
Analytics Dashboard
For additional Information Contact Thunder Support team.
Modified at 2026-07-08 15:59:35
Next
Webhooks Integration
Built with