# Google Analytics with Hubspot 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>
```

## Complete ID mapping

### Hubspot Forms

#### **Choose your CRM provider**

* [**Hubspot**](#hubspot)
* [**Salesforce**](#salesforce)

***

### **Hubspot**

#### Choose your Google Analytics implementation method:

* [**Google Analytics**](#google-analytics)
* [**Google Tag Manager**](#google-tag-manager)

***

### **Google Analytics**

If you have Google Analytics 4 implemented directly on your website, you’re all set! The tag will automatically send HubSpot form submissions to GA4.

***

### **Google Tag Manager**

If you’re using Google Tag Manager, you need to add a custom event and variable. You can skip all the instructions below and we can do it for you (if you prefer)

* [**Have Roadway add event and variable**](#have-roadway-add-event-and-variable)
* [**Add event and variable myself**](#add-event-and-variable-myself)

***

#### **Have Roadway add event and variable:**

<mark style="color:orange;">📌</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**This is for Google Tag Manager only.**</mark>

1. In **Admin**, under the **Account** column, click **User Management**.
2. In the **User Management** panel, click the **+** button, then click **Add users**.
3. Enter **<service@roadwayai.com>** in the email field.
4. Select **Notify new users by email** to send an invitation to the user.
5. Assign the following permissions:
   * **Account Permissions**: Choose **User** or **Administrator** as needed.
   * **Container Permissions**: Select **Publish** for the relevant container(s).
6. Click **Invite** to send the invitation.

***

#### **Add event and variable myself:**

* **Create and configure Custom Event Trigger:**
  1. Click on **"Triggers"** in the left-hand menu.
  2. Click **"New"**.
  3. Name your trigger `Roadway Custom Event - hubspot_form_submission` on the top left
  4. Click on **"Trigger Configuration"**.
  5. Select **"Custom Event"**.
  6. In the **"Event Name"** field, enter `hubspot_form_submission`.
  7. Choose **"All Custom Events"**.
  8. Click **"Save"** to finalize the trigger.
* **Create the hubspot\_utk Variable:**
  1. Go to **"Variables"**, Click **"New"**.
  2. Select **"Data Layer Variable",** Name it `DL - hubspot_utk` on the top left
  3. Set the **"Data Layer Variable Name"** field to `hubspot_utk`.
  4. Save the variable.
* **Create and configure GA4 Event Tag:**
  1. In GTM, click on **"Tags"** in the left-hand menu.
  2. Click **"New",** Name your tag `Roadway GA4 - HubSpot Form Submission`.
  3. Click on **"Tag Configuration"**.
  4. Select **"Google Analytics: GA4 Event"**.
  5. In the **"Configuration Tag"** dropdown, select your existing GA4 Configuration tag.
     1. If you don’t have one, set it up first by inputting your [**Measurement ID**](https://support.google.com/analytics/answer/9539598?hl=en).
  6. In the **"Event Name"** field, enter the exact name of your custom event: `hubspot_form_submission`.
  7. Scroll down to the **"Event Parameters"** section, Click **"Add Row"** to add two new parameters.

     <table data-header-hidden><thead><tr><th width="418"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter Name</strong></td><td><strong>Value</strong></td></tr><tr><td>hubspot_utk</td><td><code>{{DL - hubspot_utk}}</code></td></tr></tbody></table>
  8. Click on **"Triggering",** select the custom event trigger `Roadway Custom Event - hubspot_form_submission`.
  9. Click **"Save",** submit and publish the GTM container.

### Salesforce

### Google Analytics/Tag Manager/Segment (JS embed)

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. You can skip all the instructions below and we can do it for you (if you prefer).

* [**Have Roadway add hidden field, property, and mapping for me**](#have-roadway-add-hidden-field-property-and-mapping-for-me)
* [**Add hidden field, property, and mapping myself**](#add-hidden-field-property-and-mapping-myself)

***

#### Have Roadway add hidden field, property, and mapping for me:

<mark style="color:orange;">📌</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**This is for Salesforce only.**</mark>

* In **Setup**, under the **Administration** section, click **Users**.
* In the **Users** panel, click the **New User** button, enter **<service@roadwayai.com>** in the email field.
* Check **Generate new password and notify user immediately** to send an email invitation to the user.
* Set the following permissions:
  * **Profile**: Choose **System Administrator** access level.
  * **Role**: Assign an appropriate role if your organization uses roles.
* Click **Save** to create the user account and send the invitation.

***

#### Add hidden field, property, and mapping myself:

* **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.
  * Save the Property: After verifying the details, click "Create" to finalize the new contact property.
* **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 Salesforce contact 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 HubSpot contact field to Salesforce contact field:**

  1. Navigate to your HubSpot account settings.
  2. Click on "Integrations" and select "Salesforce."
  3. Confirm that "contact created or updated in (hubspot) -> create or update the contact (in salesforce)
  4. Navigate to Contacts property mappings
  5. Under the "Field Mappings" section, click select "Add new field mapping”
  6. Select `ga4_pseudo_user_id` from the HubSpot form fields list and map it to `ga4_pseudo_user_id` in Salesforce contact properties.
  7. Click "Save" to apply the mapping.

  Guidance can be found here: [HubSpot-Salesforce Integration Field Mapping](https://knowledge.hubspot.com/salesforce/set-up-and-use-salesforce-custom-object-sync?hubs_content=knowledge.hubspot.com%2Fsalesforce%2Finstall-the-hubspot-salesforce-integration\&hubs_content-cta=Salesforce%2520integration%2520settings).


---

# 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-hubspot-forms/google-analytics-with-hubspot-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.
