<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Toni Bitencourt</title>
    <description>The latest articles on DEV Community by Toni Bitencourt (@tonibitencourt).</description>
    <link>https://dev.to/tonibitencourt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4267911%2Fd5a55618-a248-4c26-95af-9302a5ebfd33.png</url>
      <title>DEV Community: Toni Bitencourt</title>
      <link>https://dev.to/tonibitencourt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tonibitencourt"/>
    <language>en</language>
    <item>
      <title>Server-side GTM preview opens blank: the preview server you're missing</title>
      <dc:creator>Toni Bitencourt</dc:creator>
      <pubDate>Fri, 27 Nov 2026 02:20:03 +0000</pubDate>
      <link>https://dev.to/tonibitencourt/server-side-gtm-preview-opens-blank-the-preview-server-youre-missing-5469</link>
      <guid>https://dev.to/tonibitencourt/server-side-gtm-preview-opens-blank-the-preview-server-youre-missing-5469</guid>
      <description>&lt;p&gt;You set up a server-side Google Tag Manager container on your own server, open Preview, and get a blank screen. Nothing in the logs explains it. On a self-hosted setup, the cause is almost always the same: the preview server is missing or misconfigured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A self-hosted server container runs as &lt;strong&gt;two containers&lt;/strong&gt;: the tagging server and the &lt;strong&gt;preview server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PREVIEW_SERVER_URL&lt;/code&gt; must be a &lt;strong&gt;public HTTPS URL&lt;/strong&gt;. An internal Docker hostname is rejected and the tagging container crash-loops.&lt;/li&gt;
&lt;li&gt;The preview server needs &lt;strong&gt;its own subdomain with SSL&lt;/strong&gt;, behind your reverse proxy.&lt;/li&gt;
&lt;li&gt;Set the &lt;strong&gt;Server container URL&lt;/strong&gt; in GTM Admin, or Preview won't open.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The two-container setup
&lt;/h2&gt;

&lt;p&gt;Both containers use the same official image and the same container config. One runs as the preview server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sgtm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;CONTAINER_CONFIG&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"${CONTAINER_CONFIG}"&lt;/span&gt;
      &lt;span class="na"&gt;PREVIEW_SERVER_URL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://sgtm-preview.example.com"&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:8081:8080"&lt;/span&gt;
  &lt;span class="na"&gt;sgtm-preview&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;CONTAINER_CONFIG&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"${CONTAINER_CONFIG}"&lt;/span&gt;
      &lt;span class="na"&gt;RUN_AS_PREVIEW_SERVER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"true"&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:8082:8080"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each one sits behind the reverse proxy on its own subdomain with a certificate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the internal hostname fails
&lt;/h2&gt;

&lt;p&gt;The tagging server validates &lt;code&gt;PREVIEW_SERVER_URL&lt;/code&gt; and accepts only &lt;code&gt;https://&lt;/code&gt; addresses. If you point it at the Docker service name over HTTP, the container stops with an invalid preview server URL error and restarts in a loop. The fix is a public subdomain for the preview server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three more things to check
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Docker is actually running.&lt;/strong&gt; &lt;code&gt;docker --version&lt;/code&gt; only proves the client exists. If you see &lt;code&gt;dial unix /var/run/docker.sock: no such file or directory&lt;/code&gt;, run &lt;code&gt;systemctl start docker &amp;amp;&amp;amp; systemctl enable docker&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The port is free.&lt;/strong&gt; Check with &lt;code&gt;ss -tlnp | grep 8081&lt;/code&gt; before choosing ports. On cPanel servers, 8080 is often taken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;.env&lt;/code&gt; wasn't mangled.&lt;/strong&gt; Write it with a quoted heredoc (&lt;code&gt;cat &amp;lt;&amp;lt; 'EOF' &amp;gt; .env&lt;/code&gt;) so the shell doesn't expand characters inside the container config.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why it's worth fixing
&lt;/h2&gt;

&lt;p&gt;The server Preview is the only place that shows what reached the server and which tag fired. Without it, you're validating the Conversions API blind.&lt;/p&gt;

&lt;p&gt;This setup, including the reverse proxy for cPanel and nginx, is section 5 of the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=server-side-gtm-preview-blank" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;. The free &lt;a href="https://tonibitencourt.gumroad.com/l/13-silent-tracking-failures?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=server-side-gtm-preview-blank" rel="noopener noreferrer"&gt;13 Silent Tracking Failures&lt;/a&gt; field guide lists the other failures that break server-side tracking without an error.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why does the server container preview open blank?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A self-hosted server container needs a second container running as the preview server. Without it, or with a PREVIEW_SERVER_URL that isn't a public HTTPS address, the debug interface has nothing to talk to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can PREVIEW_SERVER_URL point to the Docker service name?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. The value must be a public HTTPS URL. An internal hostname like &lt;a href="http://sgtm-preview:8080" rel="noopener noreferrer"&gt;http://sgtm-preview:8080&lt;/a&gt; is rejected and the tagging container fails to start with an invalid preview server URL error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does Preview refuse to open at all?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Check that the Server container URL is set in the container's Admin settings. Without it, Preview doesn't start.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://lp.bitencourtco.com/kit-tracking/en/guides/server-side-gtm-preview-blank/" rel="noopener noreferrer"&gt;https://lp.bitencourtco.com/kit-tracking/en/guides/server-side-gtm-preview-blank/&lt;/a&gt; by Bitencourt &amp;amp; Co. The full setup, from the ad click to HubSpot deal stages back to Meta, is in the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=server-side-gtm-preview-blank" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>marketing</category>
      <category>tracking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to send HubSpot deal stages to the Meta Conversions API</title>
      <dc:creator>Toni Bitencourt</dc:creator>
      <pubDate>Fri, 27 Nov 2026 01:50:03 +0000</pubDate>
      <link>https://dev.to/tonibitencourt/how-to-send-hubspot-deal-stages-to-the-meta-conversions-api-10o1</link>
      <guid>https://dev.to/tonibitencourt/how-to-send-hubspot-deal-stages-to-the-meta-conversions-api-10o1</guid>
      <description>&lt;p&gt;Your campaign records leads. HubSpot records who qualified and who bought. Unless something connects the two, Meta never learns which leads turned into customers, and keeps optimizing for whoever fills in the form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When a deal changes stage in HubSpot, send an event to the Meta Conversions API: &lt;strong&gt;Qualified&lt;/strong&gt;, &lt;strong&gt;Disqualified&lt;/strong&gt; and &lt;strong&gt;Purchase&lt;/strong&gt; with the deal amount.&lt;/li&gt;
&lt;li&gt;The identifiers that let Meta match the event (&lt;code&gt;fbc&lt;/code&gt;, &lt;code&gt;fbp&lt;/code&gt;, or the Lead Ads ID) must be stored &lt;strong&gt;when the lead is created&lt;/strong&gt;. They can't be recovered later.&lt;/li&gt;
&lt;li&gt;In HubSpot, store them on the &lt;strong&gt;contact&lt;/strong&gt;, then follow the deal's association to read them.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;action_source: system_generated&lt;/code&gt;, &lt;code&gt;custom_data.event_source: "crm"&lt;/code&gt; and a stable &lt;code&gt;event_id&lt;/code&gt; per deal and stage.&lt;/li&gt;
&lt;li&gt;Check HubSpot's native Meta events first. If they cover your case, you may not need any code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: store the identifier when the lead is born
&lt;/h2&gt;

&lt;p&gt;This is the step that can't be fixed later. For leads from your site, save the &lt;code&gt;_fbc&lt;/code&gt; and &lt;code&gt;_fbp&lt;/code&gt; cookies, plus email and phone, into contact properties at submission. For leads from Meta's instant forms, save the &lt;code&gt;leadgen_id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create contact properties with clear internal names, for example &lt;code&gt;meta_fbc&lt;/code&gt;, &lt;code&gt;meta_fbp&lt;/code&gt; and &lt;code&gt;meta_lead_id&lt;/code&gt;. Your code always uses the internal name, never the label.&lt;/p&gt;

&lt;p&gt;Two details catch most people: &lt;code&gt;_fbc&lt;/code&gt; only exists when the visitor arrived with an &lt;code&gt;fbclid&lt;/code&gt; in the URL, and it only works within the same domain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: detect stage changes
&lt;/h2&gt;

&lt;p&gt;With a HubSpot Service Key (legacy private apps can no longer be created), there are no webhooks, so a small bot polls the deals search endpoint every few minutes for deals modified since the last run, filtered by your pipeline.&lt;/p&gt;

&lt;p&gt;For each deal that reached a tracked stage, it reads the deal's associated contact and takes the identifiers from there. Compare stages by their internal ID (&lt;code&gt;closedwon&lt;/code&gt;, or a numeric ID in custom pipelines), never by label.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: build the Conversions API event
&lt;/h2&gt;

&lt;p&gt;The payload has four details that decide whether Meta uses it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;action_source&lt;/code&gt; is &lt;code&gt;system_generated&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;custom_data&lt;/code&gt; carries &lt;code&gt;lead_event_source&lt;/code&gt; (your CRM name) and &lt;code&gt;event_source: "crm"&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;user_data&lt;/code&gt; has &lt;code&gt;lead_id&lt;/code&gt; for instant-form leads, or &lt;code&gt;fbc&lt;/code&gt; and &lt;code&gt;fbp&lt;/code&gt; in plain text plus email and phone hashed with SHA-256;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;event_id&lt;/code&gt; is stable per deal and stage, like &lt;code&gt;&amp;lt;deal id&amp;gt;_won&lt;/code&gt;, so a reprocessed run doesn't count twice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For Purchase, add &lt;code&gt;value&lt;/code&gt; and &lt;code&gt;currency&lt;/code&gt; from the deal. HubSpot returns &lt;code&gt;amount&lt;/code&gt; as a string and it may be empty when the stage moves before the rep fills it in, so wait a cycle instead of sending zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: keep outbound out of the signal
&lt;/h2&gt;

&lt;p&gt;If the same pipeline gets paid leads and prospecting or referral deals, check for a paid-origin mark before sending anything. Otherwise every outbound sale becomes a Purchase credited to your campaigns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to start
&lt;/h2&gt;

&lt;p&gt;Start with Purchase: it's the only event with real value. Add Qualified next. If your funnel closes few deals a month, keep the campaign optimizing on a higher-volume event and use Purchase to judge quality.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=hubspot-deal-stages-meta-conversions-api" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt; has this bot ready in Python, built for HubSpot's 2026-03 API, plus the three layers before it (browser, web GTM and server-side GTM with deduplication) and a 12-step validation ladder.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Isn't HubSpot's native Meta integration enough?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes. HubSpot can send ad conversion events to Meta based on lifecycle stage changes and HubSpot form submissions, on Marketing Hub Starter and above. It doesn't cover deal stages in any pipeline, forms outside HubSpot or a pixel that lives in GTM with server-side tracking. Don't run both for the same conversions, or Meta receives each one twice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What action_source should a CRM event use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;system_generated. The event didn't happen in a browser. Also include custom_data.lead_event_source with your CRM name and custom_data.event_source set to crm, otherwise Meta may accept the event and not use it for lead optimization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Should fbc and fbp be hashed?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Click and browser identifiers go in plain text. Only personal data like email and phone are hashed with SHA-256.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://lp.bitencourtco.com/kit-tracking/en/guides/hubspot-deal-stages-meta-conversions-api/" rel="noopener noreferrer"&gt;https://lp.bitencourtco.com/kit-tracking/en/guides/hubspot-deal-stages-meta-conversions-api/&lt;/a&gt; by Bitencourt &amp;amp; Co. The full setup, from the ad click to HubSpot deal stages back to Meta, is in the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=hubspot-deal-stages-meta-conversions-api" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>marketing</category>
      <category>tracking</category>
      <category>hubspot</category>
    </item>
    <item>
      <title>Meta Conversions API deduplication: why your cost per conversion just halved</title>
      <dc:creator>Toni Bitencourt</dc:creator>
      <pubDate>Fri, 27 Nov 2026 01:24:56 +0000</pubDate>
      <link>https://dev.to/tonibitencourt/meta-conversions-api-deduplication-why-your-cost-per-conversion-just-halved-2n1f</link>
      <guid>https://dev.to/tonibitencourt/meta-conversions-api-deduplication-why-your-cost-per-conversion-just-halved-2n1f</guid>
      <description>&lt;p&gt;You turn on the Conversions API, and a few days later cost per conversion drops by half. It looks like the best week of the account. Usually it isn't: Meta is counting the same conversion twice, once from the browser and once from the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The pixel and the Conversions API send the &lt;strong&gt;same event through two paths&lt;/strong&gt;. Meta merges them only when both carry the &lt;strong&gt;same &lt;code&gt;event_id&lt;/code&gt;&lt;/strong&gt; and the same event name.&lt;/li&gt;
&lt;li&gt;A sudden efficiency gain right after turning on server-side tracking is a &lt;strong&gt;warning sign&lt;/strong&gt;, not a win.&lt;/li&gt;
&lt;li&gt;Create the &lt;code&gt;event_id&lt;/code&gt; &lt;strong&gt;once, on the page&lt;/strong&gt;, and pass the same value to the pixel and to the &lt;code&gt;dataLayer&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check it in Events Manager with a test code: the same &lt;code&gt;event_id&lt;/code&gt; should appear from &lt;strong&gt;Browser and Server&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why double counting looks like good news
&lt;/h2&gt;

&lt;p&gt;The campaign's spend doesn't change; the number of conversions it reports does. Twice the conversions for the same spend means half the cost per conversion. Optimization also starts learning from inflated counts, which is worse than the reporting problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Meta deduplication works
&lt;/h2&gt;

&lt;p&gt;Meta compares events from the pixel and the Conversions API. When the event name and the &lt;code&gt;event_id&lt;/code&gt; match, it keeps one. In the pixel, the ID goes in the options object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fbq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'trackCustom'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'lead_submitted'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;eventID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eventId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the server, it goes in the &lt;code&gt;event_id&lt;/code&gt; field of the event. With server-side GTM, the GA4 hit carries it from the browser and the Conversions API tag forwards it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern that keeps one ID
&lt;/h2&gt;

&lt;p&gt;Generate the ID once, where the event is born, and hand the same value to every destination:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;eventId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'e_'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'_'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eventId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;fbq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'trackCustom'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;eventID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eventId&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dataLayer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two rules come with it: one try/catch per destination, so a failure in one doesn't silently stop the others, and no second ID generated in GTM or on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to check deduplication
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add a Test Event Code to the Conversions API tag.&lt;/li&gt;
&lt;li&gt;Open Events Manager → Test events and walk the funnel in a normal browser window.&lt;/li&gt;
&lt;li&gt;Each conversion should show up from &lt;strong&gt;Browser&lt;/strong&gt; and &lt;strong&gt;Server&lt;/strong&gt; with the same &lt;code&gt;event_id&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Remove the Test Event Code and publish. A forgotten test code makes production events count as tests, which is another silent failure.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Related failures worth checking
&lt;/h2&gt;

&lt;p&gt;Deduplication is one of 13 silent failure modes covered in the free field guide &lt;a href="https://tonibitencourt.gumroad.com/l/13-silent-tracking-failures?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=meta-capi-deduplication-event-id" rel="noopener noreferrer"&gt;13 Silent Tracking Failures&lt;/a&gt;. The full setup, from the page to HubSpot deal stages flowing back to Meta, is in the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=meta-capi-deduplication-event-id" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How does Meta deduplicate browser and server events?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the pixel and the Conversions API send the same event with the same event name and the same event_id, Meta keeps one. In the pixel the ID goes in the eventID option; on the server it goes in the event_id field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where should the event_id be created?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once, where the event is born, on the page. The same value goes to the pixel and to the dataLayer, and from there to the server. Generating it twice, in two places, is the same as not having it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do CRM events need deduplication?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not with the browser, because there's no browser counterpart. They still need a stable event_id per record and stage, so a script that runs twice doesn't send the same conversion twice.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://lp.bitencourtco.com/kit-tracking/en/guides/meta-capi-deduplication-event-id/" rel="noopener noreferrer"&gt;https://lp.bitencourtco.com/kit-tracking/en/guides/meta-capi-deduplication-event-id/&lt;/a&gt; by Bitencourt &amp;amp; Co. The full setup, from the ad click to HubSpot deal stages back to Meta, is in the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=meta-capi-deduplication-event-id" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>marketing</category>
      <category>tracking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>HubSpot private apps can't be created anymore: what to use for server-side integrations</title>
      <dc:creator>Toni Bitencourt</dc:creator>
      <pubDate>Fri, 27 Nov 2026 01:24:55 +0000</pubDate>
      <link>https://dev.to/tonibitencourt/hubspot-private-apps-cant-be-created-anymore-what-to-use-for-server-side-integrations-1247</link>
      <guid>https://dev.to/tonibitencourt/hubspot-private-apps-cant-be-created-anymore-what-to-use-for-server-side-integrations-1247</guid>
      <description>&lt;p&gt;If you've tried to create a private app in HubSpot recently and the option wasn't there, you're not doing anything wrong. HubSpot changed how server-to-server integrations get their credentials, and most tutorials online still describe the old path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key points
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Since October 26, 2026, existing HubSpot accounts can no longer create &lt;strong&gt;legacy private apps&lt;/strong&gt; (the old &lt;code&gt;pat-&lt;/code&gt; tokens). New accounts lost the option earlier, on September 28.&lt;/li&gt;
&lt;li&gt;Private app tokens that already exist &lt;strong&gt;keep working&lt;/strong&gt;. HubSpot has announced the end of support for legacy apps and for v1 to v3 APIs in &lt;strong&gt;September 2027&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;For a new server-side script, the credential is a &lt;strong&gt;Service Key&lt;/strong&gt;: created in settings, scoped, sent as a Bearer token.&lt;/li&gt;
&lt;li&gt;Service Keys &lt;strong&gt;don't support webhooks&lt;/strong&gt;. If your integration reacts to changes, poll the search API instead.&lt;/li&gt;
&lt;li&gt;New code should use the &lt;strong&gt;date-versioned API paths&lt;/strong&gt; (for example &lt;code&gt;/crm/objects/2026-03/deals&lt;/code&gt;) instead of &lt;code&gt;/crm/v3/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What changed with HubSpot private apps
&lt;/h2&gt;

&lt;p&gt;Private apps were the simple way to give a script access to your HubSpot data: create the app, pick scopes, copy a token. That flow is now closed for new legacy apps. HubSpot's direction is two credential types: project-based apps built with the developer platform, and Service Keys for straightforward data integrations.&lt;/p&gt;

&lt;p&gt;For a typical marketing or sales operations script (read deals, read contacts, send events somewhere else), a Service Key covers it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a HubSpot Service Key
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Settings → Integrations → Service Keys&lt;/strong&gt;. In some accounts the menu is &lt;strong&gt;Development → Keys → Service Keys&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Create a key and give it a name that says what it does, for example &lt;em&gt;Meta CAPI return bot&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Add only the scopes the script needs. For reading deals and their contacts: &lt;code&gt;crm.objects.deals.read&lt;/code&gt;, &lt;code&gt;crm.objects.contacts.read&lt;/code&gt; and &lt;code&gt;crm.schemas.deals.read&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Copy the key once and store it in the script's environment, never in the code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's sent like any Bearer token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s -H &lt;span class="s2"&gt;"Authorization: Bearer $HUBSPOT_KEY"&lt;/span&gt; \
  &lt;span class="s2"&gt;"https://api.hubapi.com/crm/pipelines/2026-03/deals"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That call is also the fastest way to get the internal IDs of your pipeline stages, which is what your code should compare against (never the stage labels, someone will rename them).&lt;/p&gt;

&lt;h2&gt;
  
  
  No webhooks: poll the search API instead
&lt;/h2&gt;

&lt;p&gt;The one real limitation: Service Keys don't support webhooks. Webhooks need a project-based app built with the HubSpot CLI.&lt;/p&gt;

&lt;p&gt;For most integrations, polling is the more robust option anyway. Every few minutes, search for records modified since the last run:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;filter on &lt;code&gt;hs_lastmodifieddate&lt;/code&gt; with operator &lt;code&gt;GTE&lt;/code&gt; and a value in epoch milliseconds;&lt;/li&gt;
&lt;li&gt;sort ascending by the same property, up to 200 results per page;&lt;/li&gt;
&lt;li&gt;keep the search limits in mind: 5 requests per second per account and a cap of 10,000 results per query;&lt;/li&gt;
&lt;li&gt;move your cursor back a few minutes on every run, because the search index takes a moment to reflect an update, and keep a per-record history so the overlap doesn't create duplicates.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to do if you still run on a private app token
&lt;/h2&gt;

&lt;p&gt;Nothing breaks today. Put two things on the calendar: replace the token with a Service Key, and move your endpoints to the date-versioned paths. Both are small changes if your code keeps the base path and the credential in configuration, not scattered through the script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this matters most: sending CRM stages back to ad platforms
&lt;/h2&gt;

&lt;p&gt;A common use for these scripts is closing the loop between HubSpot and Meta Ads: when a deal is qualified or won, an event goes to the Conversions API so campaigns learn which leads actually turn into customers. That's layer 4 of the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=hubspot-private-apps-service-keys" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;, which builds the whole path with a Service Key, the 2026-03 API and polling, including the HubSpot API pitfalls that return status 200 and do nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do my existing HubSpot private app tokens stop working?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Tokens from legacy private apps that already exist keep working. What changed is that existing accounts can no longer create new legacy private apps. HubSpot has announced the end of support for legacy apps and for the v1 to v3 APIs in September 2027, so plan the migration before then.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What replaces private apps for a simple server-to-server script?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Service Key. You create it in the account settings, give it only the scopes the script needs, and send it as a Bearer token. For a script that reads deals and contacts, read-only CRM scopes are enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can I receive HubSpot webhooks with a Service Key?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. Webhooks require a project-based app built with the HubSpot CLI. With a Service Key, the robust alternative is polling the search API every few minutes for records modified since the last run.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://lp.bitencourtco.com/kit-tracking/en/guides/hubspot-private-apps-service-keys/" rel="noopener noreferrer"&gt;https://lp.bitencourtco.com/kit-tracking/en/guides/hubspot-private-apps-service-keys/&lt;/a&gt; by Bitencourt &amp;amp; Co. The full setup, from the ad click to HubSpot deal stages back to Meta, is in the &lt;a href="https://tonibitencourt.gumroad.com/l/4-layer-tracking?utm_source=devto&amp;amp;utm_medium=crosspost&amp;amp;utm_campaign=hubspot-private-apps-service-keys" rel="noopener noreferrer"&gt;4-Layer Tracking Kit&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>marketing</category>
      <category>tracking</category>
      <category>hubspot</category>
    </item>
  </channel>
</rss>
