Tracking Script Installation
Follow these steps to enable analytics on your website
Quick Setup
<script defer src="https://app.qranalytica.com/tracker.js" ></script>
Add this script to your website's <head>
section.
Implementation Examples
Track Custom Events
window.qrAnalytica.trackCustomEvent('purchase_completed', { orderId: 'ORD123', value: 99.99 });
User Identification
window.qrAnalytica.identifyUser('user@example.com');
Campaign Tracking
window.qrAnalytica.trackCustomEvent('campaign_view', { campaignId: 'summer2024', source: 'qr-code' });
Proxy Analytics with Next.js
Learn how to proxy QRAnalytica through your domain to bypass adblockers and improve accuracy.
1. Add Configuration File
// next.config.js module.exports = { async rewrites() { return [ { source: '/tracker.js', destination: 'https://app.qranalytica.com/tracker.js', }, { source: '/api/track/event', destination: 'https://api.qranalytica.com/api/track/event', }, ] }, }
Create or update your next.config.js file with these rewrite rules.
2. Update Script Tag
<script defer src="/tracker.js" ></script>
Replace the default script tag with this proxied version.
Verification Steps
- 1Deploy your site with the new configuration
- 2Open your browser's developer tools (Network tab)
- 3Verify requests are going through your domain
Automatic Tracking
- Page Views
- Click Events
- Session Duration
- Device Info
Custom Tracking
- Conversion Events
- User Identification
- Campaign Attribution
- Custom Metrics
Privacy Compliance
Ensure your privacy policy includes information about data collection through this tracking script. User identification requires explicit consent.