← Back to Insights

Framer: OpenAI Ads Pixel and CAPI for Framer Sites: Complete Setup

Step-by-step setup guide for OpenAI Ads Measurement Pixel and Conversions API (CAPI) on Framer sites using custom head scripts, form events, and webhook relays.

2026-03-31 • CMS & Website Builders

Framer is widely used for modern web projects, but sites built on Framer run as React Single Page Applications.

Single Page Applications do not trigger standard browser page reloads when visitors navigate between pages. Instead, React swaps DOM elements dynamically. If your OpenAI Ads pixel only fires during the initial document load, all subsequent internal page transitions are ignored. When combined with browser privacy protections and ad blockers, client-only tracking misses critical visitor actions.

Accurate tracking on Framer requires two cooperating components: installing the base pixel in Framer custom code with a route-change listener, and directing form submissions through a serverless edge webhook for CAPI delivery.

Here is how to configure hybrid tracking on Framer while maintaining fast page load speeds.

Adding the base pixel in Framer settings

Install the measurement script in your global site configuration:

  1. Open your project in Framer and select Site Settings.
  2. Under General, navigate down to Custom Code.
  3. In the Start of <head> section, paste the base pixel snippet:

<script>
  !function(w,d,e,u,t,s){if(w.openaiAds)return;t=w.openaiAds=function(){
  t.callMethod?t.callMethod.apply(t,arguments):t.queue.push(arguments)};
  if(!w._openaiAds)w._openaiAds=t;t.push=t;t.loaded=!0;t.version='1.0';
  t.queue=[];s=d.createElement(e);s.async=!0;s.src=u;
  var f=d.getElementsByTagName(e)[0];f.parentNode.insertBefore(s,f);
  }(window,document,'script','https://bzrcdn.openai.com/pixel.js');

  openaiAds('init', 'YOUR_PIXEL_ID');
  openaiAds('track', 'PageView');
</script>

Replace YOUR_PIXEL_ID with your actual identifier from Ads Manager.

Tracking SPA route transitions

To capture page views when visitors move between pages without refreshing their browsers, add this script to the End of <body> section under Custom Code:

<script>
  (function() {
    var lastPath = window.location.pathname;

    var observer = new MutationObserver(function() {
      if (window.location.pathname !== lastPath) {
        lastPath = window.location.pathname;
        if (window.openaiAds) {
          window.openaiAds('track', 'PageView');
        }
      }
    });

    observer.observe(document.body, { childList: true, subtree: true });

    window.addEventListener('popstate', function() {
      if (window.openaiAds) {
        window.openaiAds('track', 'PageView');
      }
    });
  })();
</script>

Tracking Framer form submissions

To emit front-end Lead signals upon form submission and generate a shared event token:

<script>
  document.addEventListener('submit', function(e) {
    var form = e.target;
    if (!form || form.tagName.toLowerCase() !== 'form') return;

    var token = 'framer_lead_' + Date.now() + '_' + Math.random().toString(36).substring(2, 8);

    var hidden = form.querySelector('input[name="openai_event_id"]');
    if (!hidden) {
      hidden = document.createElement('input');
      hidden.type = 'hidden';
      hidden.name = 'openai_event_id';
      form.appendChild(hidden);
    }
    hidden.value = token;

    if (window.openaiAds) {
      window.openaiAds('track', 'Lead', {
        content_name: form.getAttribute('name') || 'Framer Form'
      }, {
        event_id: token
      });
    }
  }, true);
</script>

Server-side CAPI via edge webhook relay

Route form submissions through an edge function such as Cloudflare Workers or Formspark to guarantee delivery even when client scripts fail:

export default {
  async fetch(request, env) {
    if (request.method !== 'POST') {
      return new Response('Method Not Allowed', { status: 405 });
    }

    try {
      const data = await request.json();
      
      const eventId = data.openai_event_id || `framer_lead_${Date.now()}`;

      const hashSha256 = async (str) => {
        if (!str) return null;
        const buf = new TextEncoder().encode(str.trim().toLowerCase());
        const hash = await crypto.subtle.digest('SHA-256', buf);
        return Array.from(new Uint8Array(hash)).map(b => b.toString(16).padStart(2, '0')).join('');
      };

      const email = data.email || data.Email || data.contact_email;
      const hashedEmail = await hashSha256(email);

      const phone = data.phone || data.Phone || data.telephone;
      const hashedPhone = phone ? await hashSha256(phone.replace(/[^0-9]/g, '')) : null;

      const payload = {
        data: [
          {
            event_name: 'Lead',
            event_time: Math.floor(Date.now() / 1000),
            event_id: eventId,
            user_data: {
              ...(hashedEmail && { em: hashedEmail }),
              ...(hashedPhone && { ph: hashedPhone })
            },
            custom_data: {
              content_name: data.form_name || 'Framer Lead'
            },
            action_source: 'system_generated'
          }
        ]
      };

      const res = await fetch('https://bzr.openai.com/v1/events', {
        method: 'POST',
        headers: {
          'Authorization': `Bearer ${env.OPENAI_ADS_ACCESS_TOKEN}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(payload)
      });

      return new Response('Success', { status: res.status });
    } catch (e) {
      return new Response('Error: ' + e.message, { status: 500 });
    }
  }
};

Verification workflow

Inspect internal navigation: Open browser developer tools, filter network traffic for bzrcdn.openai.com, and click between Framer pages to confirm PageView triggers on route updates.

Submit a test inquiry: Verify that both the client pixel and the server-side edge function execute with matching event_id tokens.

Review Event Manager inside OpenAI Ads to confirm that dual lead signals fuse without duplication.

Frequently asked questions

Where do I insert the OpenAI Ads pixel in Framer?

Open Framer Site Settings, go to General, navigate to Custom Code, and insert the snippet in the Start of <head> input before republishing.

How do I track pageviews across Framer navigation?

Because Framer runs as a single-page React app, use a MutationObserver or popstate listener to trigger openaiAds('track', 'PageView') when the URL pathname changes.

How can I send server conversions from Framer forms?

Direct Framer form actions to an edge webhook or serverless function that hashes customer data using SHA-256 and transmits the event payload to https://bzr.openai.com/v1/events.

How is deduplication maintained between Framer forms and webhooks?

Generate a unique string token in the client script, attach it as a hidden form input, and pass it as the event_id in both the front-end tracking call and the server webhook payload.

Need ChatGPT tracking installed?

Configured, tested, documented.