Before You Start
- You have a DATALYR account
- You’ve created a workspace
- You have access to edit your website HTML or use a tag manager
Step 1: Get Your Container Script
- Log in to your DATALYR dashboard
- Go to Settings → Tracking
- Copy your container script:
Step 2: Add to Your Website
Option 1: Direct HTML
Add the script to your website’s<head> section:
Option 2: Google Tag Manager
If you use Google Tag Manager:- Go to Tags → New
- Click Tag Configuration
- Choose Custom HTML
- Paste your container script
- Set trigger to All Pages
- Save and publish
Option 3: Next.js
Add to your root layout or_app.tsx:
App Router (app/layout.tsx):
pages/_app.tsx):
Option 4: Webflow
- Open your Webflow project
- Click Settings (gear icon)
- Go to Custom Code tab
- Paste your container script in Head Code
- Save and publish
Option 5: WordPress
- Go to Appearance → Theme File Editor
- Select header.php
- Find the
</head>closing tag - Paste your container script before
</head> - Click Update File
Option 6: Shopify
- Go to Online Store → Themes
- Click Actions → Edit code
- Open theme.liquid
- Find the
</head>closing tag - Paste your container script before
</head> - Click Save
Step 3: Verify Installation
- Visit your website in a new browser tab
- Open browser DevTools (F12)
- Go to Console tab
- Look for:
[DATALYR Container] Initialized
Check Network Requests
- Open DevTools → Network tab
- Filter by
containerordatalyr - You should see a request to
https://ingest.datalyr.com/container-scripts - Response should return your configured scripts
Step 4: Configure Tags
Now that the container is installed, add your first tag:- Go to Dashboard → Settings → Container
- Click Add New Tag
- Configure your tag (Meta Pixel, custom script, etc.)
- Set triggers and conditions
- Save and activate
Configuration Options
Enable Debug Mode
Adddata-debug="true" to see detailed console logs:
?datalyr_debug=true to your URL:
CSP Nonce Support
If you use Content Security Policy, add a nonce:Disable Cache (Testing)
Force fresh script fetch on every load:Container + Direct Tracking
You can use both container and direct tracking together:- Attribution tracking from
dl.js - Tag management from
container.js
SPA Configuration
For Single Page Applications (React, Vue, Next.js): The container automatically detects navigation changes using:history.pushStateandhistory.replaceStateinterceptionpopstateevents- Performance Observer API
history_change trigger will fire on navigation.
Troubleshooting
Container script not loading? Check that:- Script URL is correct:
https://track.datalyr.com/container.js - Workspace ID is correct
- Ad blockers are disabled
- Script is in the
<head>section deferattribute is present
- Enable debug mode:
data-debug="true" - Check console for errors
- Verify triggers and conditions in dashboard
- Check that tags are active
- Clear cache:
?datalyr_nocache=true
- Limit number of active tags (max 100)
- Use conditional loading to reduce unnecessary scripts
- Check external script URLs for slow responses
- Enable caching (remove
datalyr_nocache)
data-csp-nonce="YOUR_NONCE"
API Access
Check container status programmatically:Next Steps
Managing Tags
Create and configure your first tag
Container Overview
Learn about Container features
Container vs Direct
Compare installation methods
Verify Tracking
Confirm everything works