1. Open Marketo and find Google Analytics Client ID field that Marketo should have brought from Salesforce. If it didn’t, follow this instruction from Marketo.

2. Add this field as a hidden field to all your forms.

3. Open one of the forms and located this hidden field. It should look something like this:

4. Locate the name attribute of this field. In this example, it’s “gacid”. But in your case, it could be called differently.

5. Add this piece JavaScript code to the website (you may need to replace “gacid” with your GA CID input name on line #35):

That’s it – now GA Client IDs should be automatically populated to the hidden fields, which will be synced with Salesforce.

Using GA Connector

Aside from UTM parameters and tracking information, GA Connector also provides the easiest method to extract GA Client ID of your website visitors. Just add the GA Connector script to your website.

While editing your form embed code, use the ID “GA_Client_ID” so the code will be:

That’s it! No more additional custom scripts. GA Connector will automatically fill up this field with the GA Client ID.

For a full list of data that you can track with GA Connector, check out this article.

Saving the Session ID

To ensure GA4 correctly groups events into the same user session, you need to send the Session ID along with the Client ID.

If you don’t send the Session ID, events may appear as “unassigned” in session-scoped dimensions within GA4.

With GA Connector, you can capture and send the Session ID in just a few steps:

  1. Add the Session ID to your form as a hidden field

  2. Add the ID “GA_Session_ID” to the hidden field.

That’s it! Your events will now include the Session ID, allowing GA4 to correctly attribute them to the right sessions.