Skip to content

tracker.getClickIdentifiers()

Returns whichever Google Ads click identifiers the tracker has captured — from the URL on the current page load, from the _tb_* cookies on prior visits, or both. Use this to forward click IDs to your server when the user submits an order, so your server-side trackConversion call can include them.

tracker.getClickIdentifiers(): ClickIdentifiers;
type ClickIdentifiers = {
gclid?: string;
gbraid?: string;
wbraid?: string;
};

Each field is present only if the corresponding identifier was captured. The return value is a shallow copy — mutating it does not affect the tracker’s internal state.

  • Synchronous; does not touch the network.
  • Reflects the tracker’s in-memory state, which is hydrated from URL params and cookies at init time and updated by updateConsent if pre-grant values were buffered.
  • If clickIdentifierStorage === 'none', this always returns {}.
import { tracker } from '@/lib/tracker.client';
async function submitCheckout(orderData: OrderInput) {
const clickIds = tracker.getClickIdentifiers();
const res = await fetch('/api/checkout', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ ...orderData, clickIds }),
});
return res.json();
}

On the server side, store the click IDs with the order:

const order = await db.orders.create({
...orderData,
gclid: clickIds.gclid,
gbraid: clickIds.gbraid,
wbraid: clickIds.wbraid,
});

Then the server-side trackConversion can attach them:

await serverTracker.trackConversion({
label: 'purchase',
transactionId: order.id,
gclid: order.gclid,
gbraid: order.gbraid,
wbraid: order.wbraid,
// ...
});