Open any page containing your gtag.js code and enter one of the following console commands…
gtag('get', window.dataLayer[1][1], 'client_id', function(result) {console.log(result)})
Note: Unmodified gtag.js code snippet presumed. If the above code fails, try replacing window.dataLayer[1][1]
with 'YOUR-STREAM-MEASUREMENT-ID'
or refer to methods below.
document.cookie.split(';').forEach((element) => { var split = element.split('='); if ('_ga' == split[0].trim()) console.log(split[1].substring(6))})
The Client ID can also be obtained by viewing your browser’s cookies. Look for the cookie named _ga
and your client_id
will the two long segments of digits including a decimal point (example from mine below).
Example: GA1.1.0000000000.0000000000
Why you might need the Google Analytics Client ID
The client_id
is necessary for sending offline events or posting server-side events using Google Analytics’ Measurement Protocol.