Skip to content

coreyhaines31/marketingskills / skills/conversion-tracking

conversion-tracking

Verified

When the user wants to set up, audit, or fix conversion tracking to Google Ads, Meta, GA4, LinkedIn, and TikTok, or asks why conversions are missing or doubled: GTM, pixels, CAPI, Enhanced Conversions, offline imports. Fire on confirmed success, not the submit click; verify a test conversion arrives; diagnose before changing; offer free paths and disclose partner tools. For tracking plans, see analytics. For attribution, see attribution. For bidding, see ads.

FileKindSize
SKILL.mdskill md29.8 KB
assets/gtm-recipes/README.mdmarkdown6.3 KB
assets/gtm-recipes/detect/detect-acuity-scheduling.jsonconfig7.0 KB
assets/gtm-recipes/detect/detect-cal-com.jsonconfig8.8 KB
assets/gtm-recipes/detect/detect-calendly.jsonconfig7.7 KB
assets/gtm-recipes/detect/detect-contact-form-7.jsonconfig6.3 KB
assets/gtm-recipes/detect/detect-divi-forms.jsonconfig5.0 KB
assets/gtm-recipes/detect/detect-elementor-forms.jsonconfig4.4 KB
assets/gtm-recipes/detect/detect-file-download.jsonconfig5.0 KB
assets/gtm-recipes/detect/detect-fluent-forms.jsonconfig6.8 KB
assets/gtm-recipes/detect/detect-formidable-forms.jsonconfig10.8 KB
assets/gtm-recipes/detect/detect-forminator.jsonconfig5.5 KB
assets/gtm-recipes/detect/detect-framer-forms.jsonconfig6.3 KB
assets/gtm-recipes/detect/detect-generic-ajax-form.jsonconfig7.8 KB
assets/gtm-recipes/detect/detect-gravity-forms.jsonconfig15.4 KB
assets/gtm-recipes/detect/detect-hubspot-forms.jsonconfig9.3 KB
assets/gtm-recipes/detect/detect-jotform.jsonconfig3.8 KB
assets/gtm-recipes/detect/detect-ninja-forms.jsonconfig8.4 KB
assets/gtm-recipes/detect/detect-phone-click.jsonconfig4.6 KB
assets/gtm-recipes/detect/detect-squarespace-forms.jsonconfig18.5 KB
assets/gtm-recipes/detect/detect-tally.jsonconfig10.4 KB
assets/gtm-recipes/detect/detect-thank-you-page.jsonconfig6.2 KB
assets/gtm-recipes/detect/detect-typeform.jsonconfig7.9 KB
assets/gtm-recipes/detect/detect-webflow-forms.jsonconfig5.6 KB
assets/gtm-recipes/detect/detect-wix-forms.jsonconfig9.5 KB
assets/gtm-recipes/detect/detect-wix-scheduling.jsonconfig5.1 KB
assets/gtm-recipes/detect/detect-wpforms.jsonconfig11.1 KB
assets/gtm-recipes/detect/detect-ws-form.jsonconfig4.7 KB
assets/gtm-recipes/event-map.jsonconfig3.1 KB
assets/gtm-recipes/send/ga4.jsonconfig1.8 KB
assets/gtm-recipes/send/google-ads.jsonconfig2.7 KB
assets/gtm-recipes/send/linkedin.jsonconfig3.8 KB
assets/gtm-recipes/send/meta.jsonconfig4.1 KB
assets/gtm-recipes/send/microsoft.jsonconfig4.0 KB
assets/gtm-recipes/send/tiktok.jsonconfig4.4 KB
assets/snippets/README.mdmarkdown17.3 KB
assets/snippets/acuity-scheduling-field.htmlother1.3 KB
assets/snippets/acuity-scheduling.jsscript3.3 KB
assets/snippets/cal-com.jsscript5.5 KB
assets/snippets/calendly.jsscript4.8 KB
assets/snippets/contact-form-7.jsscript3.9 KB
assets/snippets/divi-forms.jsscript2.6 KB
assets/snippets/elementor-forms.jsscript2.0 KB
assets/snippets/file-download.jsscript3.2 KB
assets/snippets/fluent-forms.jsscript4.3 KB
assets/snippets/formidable-forms.jsscript8.2 KB
assets/snippets/forminator.jsscript3.1 KB
assets/snippets/framer-forms.jsscript3.9 KB
assets/snippets/generic-ajax-form.jsscript5.9 KB
assets/snippets/gravity-forms.jsscript12.8 KB
assets/snippets/hubspot-forms.jsscript6.8 KB
assets/snippets/jotform.jsscript1.4 KB
assets/snippets/ninja-forms.jsscript5.9 KB
assets/snippets/phone-click.jsscript2.8 KB
assets/snippets/squarespace-forms.jsscript15.3 KB
assets/snippets/tally.jsscript7.5 KB
assets/snippets/thank-you-page.jsscript4.3 KB
assets/snippets/typeform.jsscript5.0 KB
assets/snippets/webflow-forms.jsscript3.2 KB
assets/snippets/wix-forms.jsscript7.0 KB
assets/snippets/wix-scheduling.jsscript2.7 KB
assets/snippets/wpforms.jsscript8.6 KB
assets/snippets/ws-form.jsscript2.3 KB
evals/evals.jsonconfig21.0 KB
references/audit-playbook.mdmarkdown12.6 KB
references/browser-side.mdmarkdown22.5 KB
references/conversion-moments.mdmarkdown31.3 KB
references/discrepancies.mdmarkdown13.4 KB
references/ecommerce-platforms.mdmarkdown9.9 KB
references/google-ads.mdmarkdown29.6 KB
references/meta.mdmarkdown17.8 KB
references/other-platforms.mdmarkdown19.5 KB
references/server-side.mdmarkdown31.2 KB
scripts/build_recipe.pyscript10.8 KB
scripts/check_recipes.pyexecutablescript3.2 KB

assets/snippets/calendly.js

View on GitHub
/*! Calendly conversion detection (MIT)
 *  Detects: meeting booked. Pushes dataLayer event: calendly_event_scheduled
 *  From the conversion-tracking skill in Marketing Skills */
(function () {
  'use strict';
  if (window.__ctDetectCalendly) return;
  window.__ctDetectCalendly = true;
  window.dataLayer = window.dataLayer || [];

  // The CSS selector matches only Calendly's documented exact embed host.
  // Do not read iframe.src or its `src` attribute: prefill parameters can
  // contain invitee PII. The selector engine performs the prefix match without
  // exposing the URL value to this listener.
  var CALENDLY_FRAME_SELECTOR = 'iframe[src^=\"https://calendly.com/\"]';
  var CALENDLY_ORIGIN = 'https://calendly.com';
  var API_HOSTS = { 'api.calendly.com': true, 'calendly.com': true };
  var trackedFrames = [];
  var seenPairs = [];

  function trackFrame(frame) {
    if (!frame || !frame.contentWindow) return;
    for (var i = 0; i < trackedFrames.length; i++) {
      if (trackedFrames[i].frame === frame) {
        trackedFrames[i].source = frame.contentWindow;
        trackedFrames[i].origin = CALENDLY_ORIGIN;
        return;
      }
    }
    trackedFrames.push({ frame: frame, source: frame.contentWindow, origin: CALENDLY_ORIGIN });
  }

  function scan(root) {
    if (!root || typeof root.querySelectorAll !== 'function') return;
    var frames;
    try { frames = root.querySelectorAll(CALENDLY_FRAME_SELECTOR); } catch (e) { return; }
    for (var i = 0; i < frames.length; i++) trackFrame(frames[i]);
  }

  function sourceIsTracked(event) {
    for (var i = 0; i < trackedFrames.length; i++) {
      var item = trackedFrames[i];
      try {
        if (item.frame.isConnected === true && item.frame.contentWindow === event.source && item.source === event.source && item.origin === event.origin) return true;
      } catch (e) { /* replaced or inaccessible frames fail closed */ }
    }
    return false;
  }

  function resourceIdentity(value, kind) {
    if (typeof value !== 'string' || /[?#]/.test(value)) return null;
    try {
      var url = new URL(value);
      if (url.protocol !== 'https:' || url.port || !API_HOSTS[url.hostname]) return null;
      var eventMatch = /(?:^|\/)scheduled_events\/([A-Za-z0-9_-]{1,128})\/?$/.exec(url.pathname);
      var inviteeMatch = /(?:^|\/)scheduled_events\/([A-Za-z0-9_-]{1,128})\/invitees\/([A-Za-z0-9_-]{1,128})\/?$/.exec(url.pathname);
      if (kind === 'event' && eventMatch) return { eventId: eventMatch[1].toLowerCase() };
      if (kind === 'invitee' && inviteeMatch) return { eventId: inviteeMatch[1].toLowerCase(), inviteeId: inviteeMatch[2].toLowerCase() };
    } catch (e) { return null; }
    return null;
  }

  function pairSeen(eventId, inviteeId) {
    var key = eventId + ':' + inviteeId;
    for (var i = 0; i < seenPairs.length; i++) if (seenPairs[i] === key) return true;
    seenPairs.push(key);
    return false;
  }

  function onMessage(message) {
    if (!message || !message.source || message.source === window || !sourceIsTracked(message)) return;
    var data = message.data;
    if (typeof data === 'string') {
      try { data = JSON.parse(data); } catch (e) { return; }
    }
    if (!data || typeof data !== 'object' || data.event !== 'calendly.event_scheduled') return;
    var payload = data.payload || {};
    var eventUri = payload.event && payload.event.uri;
    var inviteeUri = payload.invitee && payload.invitee.uri;
    var eventIdentity = resourceIdentity(eventUri, 'event');
    var inviteeIdentity = resourceIdentity(inviteeUri, 'invitee');
    if (!eventIdentity || !inviteeIdentity || eventIdentity.eventId !== inviteeIdentity.eventId) return;
    if (pairSeen(eventIdentity.eventId, inviteeIdentity.inviteeId)) return;
    window.dataLayer.push({ event: 'calendly_event_scheduled', event_uri: eventUri, invitee_uri: inviteeUri });
  }

  function start() {
    if (typeof document === 'undefined') return;
    scan(document);
    if (typeof MutationObserver === 'undefined' || !document.documentElement) return;
    try {
      var observer = new MutationObserver(function (mutations) {
        for (var i = 0; i < mutations.length; i++) {
          var added = mutations[i].addedNodes || [];
          for (var j = 0; j < added.length; j++) {
            var node = added[j];
            if (node && node.tagName === 'IFRAME') scan(document);
            else scan(node);
          }
          if (mutations[i].type === 'attributes' && mutations[i].attributeName === 'src') scan(document);
        }
      });
      observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['src'] });
    } catch (e) {}
  }

  if (typeof document !== 'undefined') {
    if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, false);
    else start();
  }
  window.addEventListener('message', onMessage, false);
})();
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall