Phone Tracking Script Generator
Generate customized JavaScript code for dynamic number insertion (DNI) on your website. This tool helps you create scripts that automatically swap phone numbers based on traffic sources, enabling accurate call tracking and attribution.
📞 Phone Tracking URL Builder
Enter a phone number and your website URL to generate a trackable link.
What is Dynamic Number Insertion?​
Dynamic Number Insertion (DNI) is a call tracking technology that displays different phone numbers to website visitors based on their traffic source. This allows you to:
- Track which marketing campaigns generate phone calls
- Measure ROI of different advertising channels
- Understand the complete customer journey
- Optimize marketing spend based on call conversions
How It Works​
- Visitor arrives at your website from a specific source (Google Ads, Facebook, Email, etc.)
- Script identifies the traffic source using UTM parameters or referrer data
- Number swaps dynamically to show a tracking number for that source
- Call routes to your business while tracking the source
- Data captured for attribution and analytics
Implementation Guide​
Step 1: Generate Your Script​
Use the tool above to create a customized script based on your tracking needs.
Step 2: Add to Your Website​
Place the generated script just before the closing </body>
tag on all pages:
<!-- SendSquared Phone Tracking -->
<script>
// Your generated script here
</script>
Step 3: Mark Phone Numbers​
Ensure your phone numbers are properly marked in your HTML:
<!-- Using CSS class -->
<a href="tel:+18005551234" class="phone-number">1-800-555-1234</a>
<!-- Using data attribute -->
<span data-phone="true">Call us at 1-800-555-1234</span>
<!-- Multiple formats -->
<div class="contact-phone">(800) 555-1234</div>
Step 4: Test Implementation​
- Visit your site with different UTM parameters
- Verify numbers swap correctly
- Test calls to ensure proper routing
- Check tracking data in SendSquared dashboard
Advanced Configuration​
Multiple Number Pools​
Track different campaigns with separate number pools:
const numberPools = {
'google_ads': ['+18001111111', '+18002222222'],
'facebook': ['+18003333333', '+18004444444'],
'email': ['+18005555555', '+18006666666'],
'organic': ['+18007777777', '+18008888888']
};
Custom Selectors​
Target specific elements for number replacement:
const selectors = [
'.phone-number', // Class selector
'#main-phone', // ID selector
'[data-phone]', // Attribute selector
'a[href^="tel:"]', // Tel links
'.header .phone', // Nested selector
];
Session Persistence​
Maintain the same number throughout a visitor session:
// Store in sessionStorage
if (!sessionStorage.getItem('tracking_number')) {
sessionStorage.setItem('tracking_number', selectedNumber);
}
const displayNumber = sessionStorage.getItem('tracking_number');
Best Practices​
1. Page Load Performance​
- Minimize script size
- Load asynchronously when possible
- Cache tracking numbers
- Use CDN for script delivery
2. SEO Considerations​
- Keep original number in HTML
- Use JavaScript for swapping only
- Implement structured data markup
- Test with Google's tools
3. User Experience​
- Maintain number format consistency
- Don't cause layout shifts
- Ensure click-to-call works
- Test on mobile devices
4. Tracking Accuracy​
- Use consistent UTM parameters
- Test all traffic sources
- Monitor for script errors
- Validate data regularly
Common Use Cases​
Google Ads Campaigns​
Track calls from paid search:
Source: google_cpc
Number: Shows dedicated tracking number
Attribution: Links calls to specific ad groups
Social Media Advertising​
Monitor social campaign performance:
Source: facebook_ads
Number: Unique per campaign
Attribution: Measures social ROI
Email Marketing​
Track newsletter and email blast effectiveness:
Source: email_newsletter
Number: Campaign-specific
Attribution: Email to call conversion
Organic Traffic​
Understand SEO impact on calls:
Source: organic_google
Number: Baseline tracking
Attribution: SEO value measurement
Troubleshooting​
Numbers Not Swapping​
Check script placement: Ensure script loads after DOM content
Verify selectors: Use browser console to test selector matches
Review parameters: Confirm UTM parameters are present
Test timing: Some elements may load dynamically
Incorrect Attribution​
Validate UTM tags: Check parameter formatting
Clear cache: Test in incognito/private mode
Check referrers: Some sources may block referrer data
Performance Issues​
Optimize selectors: Use specific, efficient selectors
Reduce pool size: Limit number of tracking numbers
Async loading: Load script without blocking page
Integration with SendSquared​
API Setup​
// Initialize with your API key
const sendSquared = new SendSquaredDNI({
apiKey: 'your-api-key',
poolId: 'your-pool-id'
});
Event Tracking​
// Track custom events
sendSquared.track('form_submit', {
number: displayedNumber,
source: trafficSource
});
Webhook Configuration​
Set up webhooks to receive call data:
- Call started
- Call completed
- Caller information
- Call recording available
Analytics & Reporting​
Key Metrics​
- Call Volume: Total calls by source
- Call Duration: Average talk time
- Conversion Rate: Calls per visitor
- Cost Per Call: Ad spend divided by calls
- Call Quality: Qualified vs. unqualified
Dashboard Views​
- Real-time call activity
- Source attribution reports
- Campaign performance
- ROI analysis
- Trend visualization
Compliance & Privacy​
Legal Requirements​
- Disclose call recording
- Honor do-not-call lists
- Comply with TCPA regulations
- Respect privacy laws
Best Practices​
- Anonymize caller data
- Secure storage
- Limited retention
- Clear privacy policy
Related Resources​
- UTM Builder for SMS - Create tracked links for SMS
- Phone Call Tracking Setup - Complete setup guide
- Send SMS Campaign - Create and send SMS campaigns
- Send Email Campaign - Create and send email campaigns