Pass GA4 client_id as Stripe Checkout Sessions metadata



Next.js example

import { cookies } from 'next/headers'

export default function Page() {
  const cookieStore = cookies()
  const gaClientId = cookieStore.get('_ga')

  stripe.checkout.sessions.create({
    success_url: 'https://example.com/success',
    line_items: [
      {
        price: 'price_1MotwRLkdIwHu7ixYcPLm5uZ',
        quantity: 2,
      },
    ],
    mode: 'payment',
    metadata: {
      client_id: gaClientId
    }
  });

  return '...'
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.