title: Google Analytics 4 (gtag js) 'set' command not adding data to events
body: <p>I'm trying to add data to each event I send in GA4 via javascript by using the 'set' command:</p>
  <p><a href="https://developers.google.com/tag-platform/gtagjs/reference#set" rel="nofollow noreferrer">https://developers.google.com/tag-platform/gtagjs/reference#set</a></p>
  <p>From those docs, it appears to be similar to Serilog Enrichment, but it doesn't appear to work and I don't see this data coming through.</p>
  <p>I'm using localhost + Google Analytics Debugger chrome extension. Then in the Analytics &gt; Configure &gt; DebugView I see the custom event 'hello-world' and the property 'test', but I don't see the data I add via the &quot;set&quot; command.</p>
  <p><a href="https://i.stack.imgur.com/Lrdfi.png" rel="nofollow noreferrer">GA DebugView</a></p>
  <p>I use the set command for 2 calls - first is the &quot;user_id&quot; property that does work. That must be a special case, since GA treats that differently. The 2nd is for the custom object that doesn't work.</p>
  <p>Console shows some output for both set command calls, but nothing to tell me that something has succeeded or failed</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
    &lt;!-- Global site tag (gtag.js) - Google Analytics --&gt;
    &lt;script async src="https://www.googletagmanager.com/gtag/js?id=G-SOMECODE"&gt;&lt;/script&gt;
    &lt;script&gt;
      window.dataLayer = window.dataLayer || [];
      function gtag() {
        window.dataLayer.push(arguments);
      }
      gtag('js', new Date());
  
      // Set enrichment properties for every event "on this page"
      // https://developers.google.com/tag-platform/gtagjs/reference#set
  
      gtag('set', {
        'foo': 'bar',
      });
  
      // Set the measurement id
      // https://developers.google.com/analytics/devguides/collection/gtagjs/setting-values
      gtag('config', 'G-SOMECODE');
  
      //Set the GA4 user_id and keep it set for all events
      gtag('set', {
        'user_id': 'a24b935c-03cd-47f0-af68-c60a68b31303'
      });
  
      gtag('event', 'hello-world', {
        'test': true
      });
  
    &lt;/script&gt;
    &lt;title&gt;Html Delivery&lt;/title&gt;
    &lt;script type="text/javascript"&gt;
      function myFunction() {
        // Event with nested data test. It doesnt seem to display nicely
        gtag('event', 'button-click-nested', {
          'data': {
            'type': 'nextButton'
          }
        });
        gtag('event', 'button-click', {
          'type': 'nextButton'
        });
      }
  
      function LinkFunction() {
        console.log("link click");
        gtag('event', 'link click', {
          'type': 'link'
        });
      }
    &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;button onclick="myFunction()"&gt;Next&lt;/button&gt;
    &lt;a id="myLink" href="#" title="Click to do something" onclick="LinkFunction()"&gt;link text&lt;/a&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I've tried to move the calls to above/below the config command, but it makes no difference either.</p>
  <p>There is a <a href="https://stackoverflow.com/questions/65935187/gtag-set-is-not-attaching-data-as-expected">similar question</a>, but my rep wont let me comment on it to see if its still the case. The accepted answer doesn't really help me since I wanted to be able to add any arbitrary data in this way.</p>
  <p>I have tried to setup a custom metric for this in GA (im not using GTM), but still. No data comes through.</p>
  <p>Does this just not work?</p>