Use Cases
E-commerce (WooCommerce) Track product views, cart additions, and purchases. Attribute sales to Meta, Google, or TikTok ads. Blogs & Content Sites Track pageviews, engagement, and newsletter signups. See which content drives traffic from ads. Lead Generation Capture contact form submissions and demo requests. Track cost per lead by campaign. Membership Sites Track signups, subscription starts, and member engagement.Before You Start
- You have a DATALYR account
- You’ve created a workspace
- You have admin access to your WordPress site
Installation Method
Choose one of these methods:Method 1: Using a Header/Footer Plugin (Easiest)
Recommended Plugin: Insert Headers and Footers (free)- In your WordPress admin, go to Plugins → Add New
- Search for “Insert Headers and Footers”
- Click Install Now, then Activate
- Go to Settings → Insert Headers and Footers
- Paste your DATALYR tracking script in the Scripts in Header box:
- Click Save
Method 2: Edit Theme Files Directly
Only use this method if you’re comfortable editing theme files. Changes may be lost on theme updates.
- Go to Appearance → Theme File Editor
- Click header.php in the right sidebar
- Find the
</head>closing tag - Paste your DATALYR tracking script right before
</head>:
- Click Update File
Method 3: Using functions.php
Add this to your theme’sfunctions.php file:
YOUR_WORKSPACE_ID with your actual workspace ID from DATALYR.
Get Your Tracking Code
- Log in to your DATALYR dashboard
- Go to Settings → Tracking
- Copy your tracking script
- Replace
YOUR_WORKSPACE_IDin the examples above
Verify Tracking Works
- Visit your WordPress site in a new browser tab
- Go back to your DATALYR dashboard
- Click Events in the sidebar
- You should see a
page_viewevent within 10 seconds
What Gets Tracked Automatically
Once installed, DATALYR automatically captures:- Page views on all pages and posts
- Visitor IDs (persistent across sessions)
- UTM parameters from ad campaigns
- Ad click IDs (fbclid, gclid, ttclid)
- Referrer and traffic source
- Device and browser information
Track Contact Form 7 Submissions
If you use Contact Form 7, add this to track form submissions:- Go to Plugins → Add New
- Search for “Code Snippets”
- Install and activate the plugin
- Go to Snippets → Add New
- Add this code:
- Click Save Changes and Activate
Track WooCommerce Purchases
If you use WooCommerce, track purchases automatically: Add this code via Code Snippets or your theme’sfunctions.php:
Troubleshooting
Not seeing events? Check that:- Your tracking script is in the
<head>section, not footer - You’ve cleared your WordPress cache (if using a caching plugin)
- Your workspace ID is correct
- Ad blockers are disabled
- Scripts in Header (not Scripts in Body or Footer)
- Inside PHP tags if using functions.php
Caching Plugins
If you use a caching plugin (WP Rocket, W3 Total Cache, etc.):- Clear your cache after installing DATALYR
- Some plugins have a “Never cache” option - add
/wp-admin/*if needed - The DATALYR script loads asynchronously and won’t be blocked by most caches
Next Steps
Verify Tracking
Confirm events are coming through
Track Custom Events
Track button clicks and interactions
WooCommerce Integration
Advanced WooCommerce tracking
View Your Dashboard
See your tracking data