DataPulse Tracking Script Integration
Complete guide to implementing analytics tracking with push notifications
Getting Started
DataPulse provides a lightweight tracking script that sends real-time push notifications to your phone when important events happen on your website. The script handles all analytics automatically while giving you full control over user event tracking.
Installation
Add the DataPulse tracking script to your website. Place this code in your HTML <head>
section or before the closing </body>
tag:
<script src="https://thedatapulseapp.com/api/tracking.js?website-id=your-website-id" data-website-id="your-website-id"></script>
How It Works
Once installed, the tracking script automatically:
- Initializes tracking - Creates anonymous visitor and session management
- Tracks page views - Records every page visit with load times and scroll depth
- Sets up automatic events - Based on your configuration in the iOS app
- Respects privacy - Honors Do Not Track settings and user preferences
- Sends notifications - Triggers real-time push alerts to your phone
Automatic Event Tracking
DataPulse automatically tracks these events based on your configuration in the iOS app. No additional code is required - events are detected and sent automatically when they occur.
Page Views
Page views are always tracked automatically on every page load. The script captures:
- Page URL and title - Full URL path and document title
- Referrer information - Where the visitor came from
- Load time - How long the page took to fully load
- Session context - Connected to visitor session data
Scroll Depth Tracking
Scroll depth is automatically tracked in real-time using milestone-based detection:
- 25% milestone - When user scrolls 25% down the page
- 50% milestone - When user scrolls 50% down the page
- 75% milestone - When user scrolls 75% down the page
- 100% milestone - When user reaches the bottom
Button Clicks
Automatically detects and tracks clicks on buttons if enabled in your iOS app configuration:
- <button> elements
- <input type="button"> and <input type="submit"> elements
- Elements with role="button" attribute
- Links styled as buttons (with .btn or .button classes)
Captured data includes button text, ID, CSS classes, and page context.
Form Submissions
Automatically captures form submission events if enabled in your configuration:
- Form identification - Form ID, name, and CSS classes
- Form attributes - Action URL and HTTP method
- Field count - Number of input fields in the form
- Submission context - Page URL where form was submitted
Link Clicks
Tracks clicks on links throughout your website if enabled:
- External links - Links pointing to other domains
- Internal navigation - Links to other pages on your site
- Download links - Links to files and documents
- Nested elements - Clicks on images or text inside links
Captured data includes link URL, text content, target attribute, and source page context.
Manual Event Tracking
User events are NEVER called automatically. You must manually trigger these functions in your application code when user lifecycle events occur. This gives you complete control over when and how user actions are tracked.
Track User Signup
Call this method when a new user successfully creates an account:
// After successful user registration
window.datapulse.trackSignup({
user_id: '12345',
email: 'user@example.com',
username: 'johndoe',
plan: 'premium',
source: 'homepage'
});
Parameters: Pass any user data you want to include in the signup notification. All parameters are optional.
Track User Login
Call this method when a user successfully logs into their account:
// After successful login
window.datapulse.trackLogin({
user_id: '12345',
email: 'user@example.com',
login_method: 'email',
remember_me: true
});
Track User Logout
Call this method when a user logs out of their account:
// When user logs out
window.datapulse.trackLogout({
user_id: '12345',
logout_method: 'manual'
});
Track User Deletion
Call this method when a user deletes their account:
// When user deletes account
window.datapulse.trackUserDeletion({
user_id: '12345',
deletion_reason: 'privacy_concerns',
account_age_days: 30
});
Integration Examples
Basic Setup Example
Complete example showing how to integrate DataPulse into a basic website:
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<!-- DataPulse tracking script -->
<script src="https://thedatapulseapp.com/api/tracking.js" data-website-id="your-website-id"></script>
</head>
<body>
<h1>Welcome to My Website</h1>
<!-- Automatic tracking: button clicks, forms, links work automatically -->
<button onclick="handleSignup()">Sign Up</button>
<form onsubmit="handleLogin()">...</form>
<a href="/pricing">View Pricing</a>
<script>
// Manual tracking: call when user events occur
function handleSignup() {
// Your signup logic here...
// Track the signup manually
window.datapulse.trackSignup({
user_id: newUserId,
email: userEmail,
source: 'homepage'
});
}
</script>
</body>
</html>
User Event Integration
Example of integrating user tracking with a typical authentication system:
// Integration with authentication system
class AuthManager {
async signupUser(userData) {
try {
// Your signup API call
const result = await fetch('/api/signup', {
method: 'POST',
body: JSON.stringify(userData)
});
if (result.ok) {
const user = await result.json();
// Track successful signup
window.datapulse.trackSignup({
user_id: user.id,
email: user.email,
plan: user.subscription_plan
});
return user;
}
} catch (error) {
console.error('Signup failed:', error);
}
}
async loginUser(credentials) {
try {
const result = await fetch('/api/login', {
method: 'POST',
body: JSON.stringify(credentials)
});
if (result.ok) {
const user = await result.json();
// Track successful login
window.datapulse.trackLogin({
user_id: user.id,
login_method: 'email'
});
return user;
}
} catch (error) {
console.error('Login failed:', error);
}
}
logoutUser() {
// Your logout logic
this.clearSession();
// Track logout
window.datapulse.trackLogout({
user_id: this.currentUserId
});
}
}
React Integration
Example of using DataPulse in a React application:
// React component with DataPulse integration
import { useEffect } from 'react';
function SignupForm() {
const handleSignup = async (formData) => {
try {
// Your signup logic
const response = await signupAPI(formData);
if (response.success) {
// Track signup with DataPulse
if (window.datapulse) {
window.datapulse.trackSignup({
user_id: response.user.id,
email: response.user.email,
source: 'signup_form'
});
}
// Redirect or show success
navigate('/dashboard');
}
} catch (error) {
console.error('Signup error:', error);
}
};
return (
<form onSubmit={handleSignup}>
{/* Your form fields */}
<button type="submit">Sign Up</button>
</form>
);
}
API Security & Restrictions
API Usage Restrictions
DataPulse API endpoints are designed exclusively for internal use by the tracking script. Direct API access is blocked for security reasons:
- Domain validation - All requests must originate from your registered domain
- Request origin verification - Origin and Referer headers are strictly validated
- Script-only access - Only requests from tracking.js are accepted
- Cross-domain protection - Requests from unauthorized domains are blocked
Domain Validation
DataPulse validates that all tracking requests originate from your registered domain:
- Exact domain match - yoursite.com ✅
- Subdomain support - blog.yoursite.com ✅
- www. variations - www.yoursite.com ✅
- Cross-domain blocked - malicious-site.com ❌
This ensures your analytics data can only be sent from your actual website, preventing abuse and unauthorized tracking.
Security Features
DataPulse includes enterprise-level security protections:
- JSON injection protection - Prevents malicious payloads
- Rate limiting safeguards - Protects against abuse
- Input validation - All data is sanitized and validated
- Session integrity - Cryptographically secure session management
- Privacy compliance - Respects Do Not Track and privacy settings
Troubleshooting
Debugging
If tracking isn't working as expected, check these common issues:
// Check if DataPulse is loaded
console.log('DataPulse loaded:', typeof window.datapulse !== 'undefined');
// Check current configuration
if (window.datapulse) {
console.log('Website ID:', window.datapulse.websiteId);
console.log('Selected events:', window.datapulse.selectedEvents);
console.log('Respects DNT:', window.datapulse.respectDnt);
}
// Test manual tracking
window.datapulse.trackSignup({ test: true });
Common Issues
Tracking script not loading
- Verify the script URL is correct:
https://thedatapulseapp.com/api/tracking.js
- Check that
data-website-id
attribute is set correctly - Ensure no ad blockers are preventing the script from loading
- Check browser console for any error messages
Manual events not triggering
- Verify the event is enabled in your iOS app configuration
- Check that
window.datapulse
is available before calling tracking functions - Ensure you're calling the correct function names (trackSignup, trackLogin, etc.)
- Verify your website domain matches the registered domain in DataPulse
No push notifications received
- Check notification settings in the iOS app (Settings → Notifications)
- Verify the specific event type is enabled for notifications
- Ensure push notifications are enabled in iOS Settings for DataPulse
- Check that tracking events are actually being sent (use browser dev tools)
Automatic events not working
- Verify the event types are enabled in your iOS app event configuration
- Check that the website verification is complete
- Ensure elements have proper HTML structure (buttons, forms, links)
- Verify Do Not Track is not enabled if you have DNT respect turned on
403 Forbidden errors
- This indicates domain validation failure
- Verify your website domain exactly matches what's registered in DataPulse
- Check that you're not making direct API calls instead of using tracking.js
- Ensure the script is loaded from the same domain as your website
Legal
Privacy Policy
DataPulse is committed to protecting your privacy and the privacy of your website visitors. Our privacy practices are designed to be transparent and compliant with applicable privacy laws.
Key Privacy Points:
- Anonymous Analytics - DataPulse collects anonymous visitor data without personally identifying users
- Your Control - You control what data is collected through your iOS app configuration
- Visitor Privacy - Respect for Do Not Track settings and IP anonymization options
- Data Security - Industry-standard encryption and security measures protect all data
- No Third-Party Sharing - Your analytics data is never sold or shared with third parties
Copy-Paste Privacy Policy Template
Add this section to your existing privacy policy to disclose DataPulse analytics usage:
## Website Analytics
We use DataPulse, a third-party analytics service, to collect anonymous information about how visitors use our website. [DESCRIBE YOUR SPECIFIC USE CASE - e.g., "This helps us understand user behavior and improve our website experience" or "This data helps us optimize our product offerings and marketing campaigns"].
### Information Collected by DataPulse:
- Page views and navigation paths
- Time spent on pages and scroll depth
- Button clicks, form submissions, and link interactions
- Browser type, device information, and screen resolution
- Referrer information (which website you came from)
- Geographic location (country-level only, based on IP address)
- User interactions such as signups, logins, and logouts (when applicable)
### How This Information is Used:
[CUSTOMIZE THIS SECTION FOR YOUR SPECIFIC BUSINESS PURPOSES]
- To analyze website traffic and usage patterns
- To improve website functionality and user experience
- To send push notifications to website administrators about user activity
- To generate anonymous analytics reports
- [ADD YOUR SPECIFIC USE CASES - e.g., "To optimize our marketing campaigns", "To improve our product development", "To enhance customer support"]
### Data Sharing and Storage:
- DataPulse processes this information on our behalf as a data processor
- No personally identifiable information is collected or stored
- Data is stored securely with industry-standard encryption
- We do not sell, rent, or share this analytics data with third parties
- Visitors can enable "Do Not Track" in their browser to opt out of tracking
- [ADD YOUR SPECIFIC DATA SHARING PRACTICES IF ANY]
### Your Rights:
- You can request information about data collection practices
- You can opt out of tracking by enabling "Do Not Track" in your browser
- [ADD ADDITIONAL RIGHTS SPECIFIC TO YOUR JURISDICTION - e.g., "You have the right to request deletion of your data", "You can request a copy of data we have collected"]
- For questions about DataPulse's data practices, contact: support@thedatapulseapp.com
For more information about DataPulse's privacy practices, visit: https://thedatapulseapp.com/privacy
### Data Retention:
Analytics data is retained for [SPECIFY YOUR RETENTION PERIOD] to [SPECIFY YOUR BUSINESS PURPOSE FOR RETENTION]. After this period, data may be anonymized or deleted.
Last updated: [INSERT DATE]
Customization Instructions:
- Replace ALL bracketed placeholders [ ] with your specific business information
- Customize the "How This Information is Used" section to reflect your actual business purposes
- Add your specific data sharing practices, user rights, and retention policies
- Replace [SPECIFY YOUR RETENTION PERIOD] with your actual data retention timeframe
- Replace [INSERT DATE] with the date you last updated your privacy policy
- Modify the language to match your existing privacy policy style and format
- This template cannot be used as-is - you must customize it for your specific business and legal requirements
Terms of Service
By using DataPulse tracking scripts and services, you agree to comply with our terms of service and acceptable use policies.
Key Terms Summary:
- Acceptable Use - Use DataPulse only for legitimate website analytics and monitoring
- Data Responsibility - You are responsible for complying with privacy laws in your jurisdiction
- Service Availability - We strive for 99.9% uptime but cannot guarantee uninterrupted service
- API Security - Prohibited from attempting to bypass security measures or make unauthorized API calls
- Account Termination - We reserve the right to terminate accounts that violate these terms
Copy-Paste Terms of Service Template
Add this section to your existing terms of service to address DataPulse usage:
## Website Analytics and Tracking
### Analytics Service Usage
We use DataPulse, a third-party analytics service, to monitor and analyze usage of our website [FOR THE PURPOSE OF YOUR SPECIFIC BUSINESS NEEDS - e.g., "to improve our products and services", "to optimize our marketing efforts", "to enhance user experience"]. By accessing and using our website, you acknowledge and agree to the collection and processing of analytics data as described in our Privacy Policy.
### Scope of Data Collection
Our analytics tracking may collect information about:
- Your interactions with our website (page views, clicks, form submissions)
- Technical information about your device and browser
- General location information (country-level only)
- Usage patterns and website performance metrics
- [ADD ANY ADDITIONAL DATA TYPES YOU COLLECT]
### User Consent and Opt-Out
- By continuing to use our website, you consent to analytics data collection
- You may opt out of tracking by enabling "Do Not Track" in your browser settings
- Opting out may affect certain website functionality or personalization features
- [ADD YOUR SPECIFIC CONSENT MECHANISMS IF ANY - e.g., "You can manage your preferences in our cookie settings"]
### Third-Party Service Provider
- DataPulse acts as our data processor for analytics services
- DataPulse is subject to their own terms of service and privacy policy
- We are not responsible for DataPulse's data handling practices beyond our contractual agreements
- For questions about DataPulse's practices, contact: support@thedatapulseapp.com
### Data Processing Compliance
- We process analytics data in accordance with applicable privacy laws [SPECIFY YOUR JURISDICTION'S LAWS - e.g., "including GDPR", "including CCPA", "including PIPEDA"]
- Data collection is limited to [YOUR SPECIFIC LEGITIMATE BUSINESS PURPOSES]
- We implement appropriate security measures to protect collected data
- Data retention periods are established in accordance with our Privacy Policy
### Your Responsibilities
By using our website, you agree that:
- You will not attempt to interfere with or circumvent our analytics systems
- You will not use automated tools to generate false analytics data
- You understand that analytics help us [YOUR SPECIFIC PURPOSE - e.g., "improve our services", "optimize our business operations"]
- You accept that some data collection is necessary for website operation
- [ADD ANY ADDITIONAL USER RESPONSIBILITIES SPECIFIC TO YOUR BUSINESS]
### Limitation of Liability
- We make reasonable efforts to ensure accurate analytics collection
- We are not liable for any analytics data processing errors or omissions
- We are not responsible for third-party analytics service interruptions
- Analytics data is provided "as-is" without warranties
- [ADD YOUR SPECIFIC LIABILITY LIMITATIONS]
### Changes to Analytics Practices
We reserve the right to:
- Modify our analytics collection methods with appropriate notice
- Add or remove analytics features as needed for [YOUR SPECIFIC BUSINESS PURPOSES]
- Update our data processing practices to maintain legal compliance
- Terminate analytics services at our discretion
For detailed information about our data collection and privacy practices, please review our Privacy Policy.
Last updated: [INSERT DATE]
Customization Instructions:
- Replace ALL bracketed placeholders [ ] with your specific business information
- Specify your exact business purposes for using analytics data
- Add your jurisdiction's specific privacy laws and compliance requirements
- Include any additional user responsibilities or limitations specific to your business
- Replace [INSERT DATE] with the date you last updated your terms of service
- Modify the language to match your existing terms of service style and tone
- Ensure consistency with your privacy policy disclosures
- This template cannot be used as-is - you must customize it for your specific business and legal requirements