Overview
This guide explains how to fire third-party tracking pixels, analytics scripts, or conversion codes when visitors submit forms on HeavySet Tech. This is commonly used for advertising platforms, CRM integrations, and marketing attribution tools.
How It Works
HeavySet Tech forms send event notifications to your page when a visitor submits a lead or books an appointment. You can listen for these events and execute any script you need.
The two event types are:
leadSubmission- Fired when a lead form is submittedappointmentSubmission- Fired when an appointment is booked
Basic Implementation
Step 1: Get Your Third-Party Script
First, obtain the tracking code from your advertising or analytics platform. This typically includes:
- One or more
<script>tags - Sometimes a
<noscript>fallback image pixel - Advertiser IDs, pixel IDs, or tracking parameters
Example from a typical ad platform:
<script defer src="https://cdn.adplatform.com/sdk.js"></script>
<script>
window.tracking = window.tracking || [];
tracking.track({ advertiserId: "your-advertiser-id", pixelId: "your-pixel-id" });
</script>
<noscript>
<img src="https://track.adplatform.com/pixel?id=your-id" width="0" height="0" />
</noscript>Step 2: Wrap It in a HeavySet Event Listener
Use this template to fire your script when HeavySet forms are submitted:
<script>
/* Fire once per page-view */
function fireThirdPartyPixel() {
if (window.__myPixelFired) return;
window.__myPixelFired = true;
/* Load the third-party SDK script */
const script = document.createElement('script');
script.defer = true;
script.src = 'YOUR-SDK-URL-HERE';
/* Execute tracking code once SDK loads */
script.onload = function() {
/* PASTE YOUR TRACKING CODE HERE */
window.tracking = window.tracking || [];
tracking.track({
"advertiserId": "YOUR-ADVERTISER-ID",
"pixelId": "YOUR-PIXEL-ID"
});
};
/* Fallback: fire backup pixel if SDK fails */
script.onerror = function() {
const img = new Image(0, 0);
img.referrerPolicy = 'no-referrer';
(window.__pixelImgs ||= []).push(img);
img.src = 'YOUR-FALLBACK-PIXEL-URL';
};
document.head.appendChild(script);
}
/* Listen for HeavySet events */
window.addEventListener('message', (event) => {
if (!event.origin.includes('heavyset.tech')) return;
const t = event.data?.type;
if (t === 'leadSubmission' || t === 'appointmentSubmission') {
fireThirdPartyPixel();
}
});
</script>Step 3: Deploy to Your Site Header
Add this complete script to your website's <head> section or header injection area.
Real-World Example
Here's a complete example for a typical ad tracking platform:
<script>
function fireAdPlatformPixel() {
if (window.__adPlatformPixelFired) return;
window.__adPlatformPixelFired = true;
const script = document.createElement('script');
script.defer = true;
script.src = 'https://cdn.adplatform.com/sdk.js';
script.onload = function() {
window.__adplatform__ = window.__adplatform__ || [];
__adplatform__.push(function () {
__adplatform__.track({
"advertiserId": "abc123-def456-ghi789-jkl012",
"pixelId": "xyz789-uvw456-rst123-opq890"
});
});
};
script.onerror = function() {
const img = new Image(0, 0);
img.referrerPolicy = 'no-referrer';
(window.__pixelImgs ||= []).push(img);
img.src = 'https://track.adplatform.com/pixel/advertiser/abc123-def456-ghi789-jkl012/pixelId/xyz789-uvw456-rst123-opq890';
};
document.head.appendChild(script);
}
window.addEventListener('message', (event) => {
if (!event.origin.includes('heavyset.tech')) return;
const t = event.data?.type;
if (t === 'leadSubmission' || t === 'appointmentSubmission') {
fireAdPlatformPixel();
}
});
</script>Remember to replace:
https://cdn.adplatform.com/sdk.jswith your platform's SDK URLabc123-def456-ghi789-jkl012with your actual advertiser IDxyz789-uvw456-rst123-opq890with your actual pixel IDhttps://track.adplatform.com/pixel/...with your platform's pixel URL
Key Features Explained
FeaturePurposeFire once per pagePrevents duplicate tracking if multiple forms are submittedOrigin checkSecurity measure - only listens to messages from heavyset.techDynamic script loadingLoads third-party SDK only when needed, improving page performanceFallback pixelEnsures tracking works even if the main SDK fails to loadEvent filteringOnly fires on actual submissions, not other page events
Common Use Cases
- Facebook/Meta Pixel - Track lead conversions
- Google Ads Conversion - Measure campaign ROI
- TikTok Pixel - Attribution for TikTok ads
- LinkedIn Insight Tag - B2B conversion tracking
- Custom CRM webhooks - Send data to your CRM
- Analytics platforms - Custom event tracking
Troubleshooting
Script not firing?
- Open your browser's Developer Console (F12)
- Look for messages from HeavySet Tech
- Verify the event.origin includes 'heavyset.tech'
Duplicate conversions?
- Check that the "fire once" flag (
window.__myPixelFired) has a unique name - Each third-party platform should have its own unique flag name
Need to fire on only one event type?
// Only fire on leads: if (t === 'leadSubmission') fireThirdPartyPixel(); // Only fire on appointments: if (t === 'appointmentSubmission') fireThirdPartyPixel();
Need Help?
Contact HeavySet Tech support with:
- Your website URL
- The third-party platform you're integrating
- Any error messages from your browser console
Comments
0 comments
Please sign in to leave a comment.