Advanced GTM and custom JavaScript tracking for sites that don't fit the defaults
When plugins and built-in triggers can't see what matters, I write the custom JavaScript, dataLayer logic, API calls and GTM templates that capture it accurately, without slowing your site down.
- DOM listeners & selectors
- Dynamic dataLayer events
- Cookies, storage & APIs
- Custom templates & clients
When standard GTM triggers aren't enough
GTM's built-in triggers cover simple pages. Modern sites with AJAX forms, single-page apps, custom checkouts and embedded tools need tracking that is engineered, not clicked together.
- Forms that submit with AJAX and never reload the page.
- Product and cart data that only exists in the page, not in a data layer.
- Values needed on a later page, such as the lead type on the thank-you page.
- Platforms that need data in a specific schema, such as GA4 items or Meta contents.
What I build in GTM and JavaScript
Practical tracking engineering for the parts of your site that standard triggers can't see.
DOM selectors & listeners
Capture clicks, form submissions, AJAX responses and element visibility on any page.
URL parameters
Read UTMs, click IDs and custom parameters, and pass them into forms and the CRM.
Custom JavaScript variables
Loops, conditions, arrays and objects that clean and reshape data inside GTM.
Data extraction
Read product, cart and form values from the page when no data layer exists.
Schema transformation
Turn one dataLayer into GA4 items, Meta contents and other platform formats.
Cross-page state
Carry values to later pages with URL parameters, cookies or storage, within their limits.
HTTP requests & APIs
GA4 Measurement Protocol, Meta Conversions API and Google Ads conversion uploads.
Custom templates & clients
Web tag templates and server-side clients when no existing template fits.
// Push one lead event when an AJAX form succeeds
document.addEventListener('submit', function (e) {
var form = e.target.closest('form[data-track="lead"]');
if (!form || form.dataset.sent) return;
// the success event name depends on the form plugin
form.addEventListener('ajax:success', function () {
form.dataset.sent = '1'; // prevents double fire
window.dataLayer.push({
event: 'generate_lead',
form_id: form.id,
lead_type: form.dataset.leadType || 'contact'
}); // no personal data here
}, { once: true });
}); Cookies and storage, used correctly
Cookies belong to one domain, and localStorage and sessionStorage to one origin, so none of them can share data between different domains on their own. For cross-domain journeys, values travel in URL parameters (such as GA4's cross-domain linker) or through a server. Secrets such as API keys never go into browser code.
API and server-side event delivery
Where the browser isn't enough, events are sent through HTTP APIs: the GA4 Measurement Protocol, Meta Conversions API and Google Ads conversion uploads, from a server container or backend so secrets never reach the browser.
First-party collection
Events go to your own domain first, which browsers treat as first-party.
Enrichment
Server events can add data the browser doesn't have, such as order status or customer ID.
Deduplication
Browser and server copies share an event ID, so each conversion is counted once.
What you get
- Tracking review of your pages, forms and checkout
- Custom JavaScript listeners and variables, documented in GTM
- dataLayer events with dynamic values in each platform's schema
- Cross-page state handling with cookies, storage or URL parameters as appropriate
- API-based delivery (Measurement Protocol, CAPI, Google Ads) where needed
- Custom GTM templates or server clients if required, plus a QA report
How we work together
- 01Audit
I review your current GTM & JavaScript setup, tags, forms and data flows, and list what is missing or wrong.
- 02Plan
You get a written tracking plan: events, values, identity and where each signal goes.
- 03Build
I implement the plan on your site, server and integrations, without breaking existing tracking.
- 04Verify
Every event is tested with real actions and compared with your store or CRM, then documented.
My Proven 5-Step Working Process
A clear, tested process, so you know exactly what is being tracked, why, and that it works. Nothing goes live until it is tested against real conversions.
-
Step 1: Free discovery call
Free · 30 minWe agree what counts as a real lead or sale for your business, which platforms you use and where the numbers stop adding up.
-
Step 2: Tracking audit & measurement plan
Step 1I audit your tags, GTM container, GA4, ad platform conversions and CRM, then write a tracking plan for you to approve before anything changes.
-
Step 3: Build & connect
ImplementationGA4, Google Tag Manager, server-side tracking, Meta CAPI, enhanced conversions and CRM or offline imports are built and connected end to end.
-
Step 4: Test & verify
Before go-liveEvery event is checked in GTM Preview, GA4 DebugView and each ad platform's diagnostics, with deduplication and consent tested properly.
-
Step 5: Handover & support
Docs + videoYou get written documentation and a walkthrough video, and I stay on hand after launch to make sure the data keeps matching.
GTM & JavaScript questions
Will custom JavaScript slow my site down?
Not if it's written carefully: listeners are lightweight, run only where needed and avoid blocking the page.
Can localStorage pass data between my domains?
No. localStorage and sessionStorage are limited to one origin, and cookies to one domain. Across domains, data has to travel in URL parameters (such as GA4's linker) or through a server.
Do you build custom GTM templates?
Yes, both web tag templates and server-side clients, when no suitable template exists in the Community Template Gallery.
Often combined with
Let's get your GTM & JavaScript tracking right
Tell me what you're tracking today and where the numbers don't add up. You'll get an honest assessment and a clear plan.