# Google Analytics with Custom Forms

## Google Analytics with Custom Forms

## **1. Add Roadway Tag**

Add the following script tag to the `<head>` section of your website or on Google Tag Manager to All Pages:

```
<script defer src="//analytics.roadwayai.com/tag.js"></script>
```

## **2. Salesforce CRM**

If you’re using Salesforce for your CRM, you need to add a hidden field, custom property, and map those in your integration. Roadway tag will take care of the rest.

* **Add Hidden Field to Form:**
  1. Navigate to your form
  2. Add a hidden field named `ga4_pseudo_user_id`.
* **Create Salesforce Property:**
  1. Log into Salesforce and enter the Setup menu.
  2. Navigate to Object Manager and select the "Contact" object.
  3. Click "Fields & Relationships" then select "New."
  4. Choose "Text" as the field type and set the field label to `ga4_pseudo_user_id`.
  5. Specify the field length to 255.
  6. Confirm the settings and click "Next."
  7. Click "Next" again on step 3 "Establish field-level security".
  8. Click "Save" on step 4 "Add to page layouts".
* Detailed instructions are available in the [Salesforce Custom Field Guide](https://help.salesforce.com/s/articleView?id=platform.adding_fields.htm\&type=5).
* **Map Form field to Salesforce:**
  1. Navigate to your Salesforce account settings.
  2. Click on "Integrations" and select your form integration
  3. Add the new `ga4_pseudo_user_id` field mapping to the mapping
  4. Click "Save" to apply the mapping.

## **2. Hubspot CRM**

* **Add Hidden Field to Form:**
  1. Navigate to your form
  2. Add a hidden field named `ga4_pseudo_user_id`.
* **Add Hidden Field to HubSpot Form:**

  1. Log into HubSpot, navigate to your Forms
  2. Click on the "Edit" button for the form(s) you want to edit
  3. On the "existing fields" section, search for and add the `ga4_pseudo_user_id` contact property you just created
  4. On the new `ga4_pseudo_user_id` input field, click on the "Edit" button and click the "Make this field hidden" box
  5. Click the "Update" button in top right corner

  For details, see [HubSpot Forms Guide](https://knowledge.hubspot.com/forms/create-forms#customize-your-form-options).
* **Create Hubspot contact Property:**
  * Log into HubSpot and select account "Settings" from the dropdown menu.
  * In the left sidebar menu, go to "Properties" under the "Data Management" section.
  * Click the "Create property" button in the upper right corner.
  * Configure Property Details:
    * Object Type: Select "Contact" to ensure the property is associated with contact records.
    * Group: Choose an existing property group (e.g., "Contact Information") or create a new group to organize your properties.
    * Label: Enter `ga4_pseudo_user_id` as the property name.
    * Field Type: Select "Single-line text" to match the Salesforce "Text" field type.
    * Configure field to be "Hidden".
  * Save the Property: After verifying the details, click "Create" to finalize the new contact property.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roadwayai.com/required-ids-for-attribution/implementing-the-roadway-tag/add-anonymous-ids-to-crm-with-custom-forms/google-analytics-with-custom-forms.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
