title: What should the client_id be when sending events to Google Analytics 4 using the Measurement Protocol?
body: <p>I am using Google Analytics 4 (GA4) on the client to track a whole bunch of different events. However, there are 2 scenarios that I can't cover client side:</p>
  <ol>
  <li>A user completing check out on a payment page hosted by a third-party (Stripe in this case).</li>
  <li>A refund that is made by the support team.</li>
  </ol>
  <p>These events are handled by the server using webhooks. To me it seems like the most straightforward solution, would be to let the server send the event to GA4 (as opposed to the client sending it). I believe the <code>Measurement Protocol</code> should be used for this.</p>
  <p>For each event submitted through the <code>Measurement Protocol</code> a <code>client_id</code> is required. When the client is submitting an event, this is an automatically generated ID which is used to track a particular device.</p>
  <p>My question thus is, what should the <code>client_id</code> be when submitting an event server-side?</p>
  <p>Should the same <code>client_id</code> perhaps be used for all events, as to recognize the server as one device? I have read some people proposing to use a randomly generated <code>client_id</code> for each event, but this would result in a new user to be recognized for every server-side event...</p>
  <hr />
  <p>EDIT:
  One of the answers proposes to use the <code>client_id</code>, which is part of the request as a cookie. However, for both examples given above, this cookie is not present as the request is made by a third-party webhook and not by the user.</p>
  <p>I could of course store the <code>client_id</code> in the DB, but the refund in the second example is given by the support team. And thus conceptually it feels odd to associate that event with the user's <code>client_id</code> as the <code>client_id</code> is just a way to recognize the user's device? I.e. it is not the user's device which triggered the refund event here.</p>
  <p>Another refund event example would be when user A makes a purchase with user B and user B refunds this purchase a week later. In this situation, should the <code>client_id</code> be the one of user A or of user B? Again, it feels odd to use a stored <code>client_id</code> here. Because, what if user A is logged in on two devices? Which <code>client_id</code> should be used here then?</p>