analytics newage
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Pythagoras - solutions - Measurement Protocol | Developer Instructions | Web This technikas tast containe information about setting up sening information from HubSpot CRM to GA4 thourout Measurment Protocol. These are supplemented with code snippet instructions aimed at developers who play an important role in the measurement setup. As not all data is available on the page initially, we ask developers to prepare this and provide the necessary data when certain interaction events take place. Our goal is to deploy an error-proof setup which is not prone to changes in the DOM of the website. Therefore we strive to collect as much data as possible made available through back- and frontend data streams. ## [<span class="octicon octicon-link" style="color: rgb(0, 0, 0); vertical-align: middle; visibility: hidden;"></span>](#Table-of-Contents "Table-of-Contents")Table of Contents <span class="toc"></span> ## [<span class="octicon octicon-link" style="color: rgb(0, 0, 0); vertical-align: middle; visibility: hidden;"></span>](#General-Information "General-Information")General Information Sending data from HubSpot to Google Analytics 4 requires a specific structure. All parameters must be sent in JSON format through the Measurement Protocol. The request should include key fields such as the **Measurement ID** (measurement_id), **client ID **(client_id), **session ID** and **timestamp** to identify users. Event data is structured within an event object, containing the event name and relevant event parameters. In particular, the payload must include: * **Client ID:** This is used to uniquely identify the user or device. * Measurement ID: The ID associated with the GA4 property. * **Session ID:** A unique identifier for each user session. This helps track user behavior across a single session, especially when multiple interactions occur. * **Timestamp:** The time when the event took place, ensuring that the event data is aligned accurately with user interactions, even if sent later. * **Event Name:** Describes the type of interaction (e.g., purchase, form_submission). * **Event Parameters:** Additional information related to the event, such as revenue, page title, or form field data. It's important that developers ensure all required parameters are included, such as timestamps and user information, and handle any errors or failed requests to guarantee data accuracy. The setup should also adhere to data privacy regulations, such as GDPR or CCPA, ensuring that personally identifiable information (PII) is not sent to GA4. ### Client Id After a successful meeting booking on the page https://meetings-eu1.hubspot.com/meetings/pythagoras/book-a-demo, along with other customer data, it is necessary to send the Google Analytics 4 **Client ID** to the CRM for further analysis of user actions and interactions. The **Client ID** is a unique identifier for a user or device, automatically generated by Google Analytics during the user's first visit to the website. This identifier is stored in the user's **browser cookie** and can be retrieved for transmission to the CRM. Parameter Name:` _ga` Value: `Everything that follows GA1.1.` In the screenshot below, the part highlighted in green represents what needs to be sent as the Google Analytics Client ID: ![clien_id](https://hackmd.io/_uploads/ByuFxdbAA.jpg) For instance, in the screenshot, the browser cookie appears as follows: `GA1.1.644846202.1727163978` The Client ID will be extracted as: `644846202.1727163978` This is the value that needs to be transmitted. Below is an example script that can be used to extract this parameter: ``` function() { var match = document.cookie.match('(?:^|;)\\s*_ga=([^;]*)'); var raw = (match) ? decodeURIComponent(match[1]) : null; if (raw) { match = raw.match(/(\d+\.\d+)$/); } var gacid = (match) ? match[1] : null; if (gacid) { return gacid; } } ``` ### Session Id The **Session ID** is a unique identifier assigned to each session a user has on the website. A session is a group of user interactions within a specific time frame. GA4 uses this **Session ID** to track user interactions during a single session, allowing for accurate reporting of session data, including metrics such as session duration, engagement, and conversions. By transmitting the **Session ID**, it becomes easier to link user behavior across multiple interactions within one session and provides a clearer understanding of how users engage with the site. Parameter Name: `_ga_{{GA_id}}` Value:` Everything after GS1.1. and up to the first period ` In the screenshot below, the part highlighted in greem represents what needs to be sent as the **Session ID **(GS1): ![session](https://hackmd.io/_uploads/HyAif_WA0.jpg) For example, in the screenshot, the browser cookie appears as follows: `GS1.1.1727174988.2.1.1727175042.6.0.0` The **Session ID** will be extracted as: `1727175042` This is the value that needs to be transmitted. Below is an example script that can be used to extract this parameter: ``` function getSessionNumber() { // Example GA Stream ID const pattern = /_ga_Q7XTW38WLL=GSd.d.(w+).(d+)/; const match = document.cookie.match(pattern); const sessionNumber = match?.[2]; if (!sessionNumber) { // Cookie not yet available; wait a bit and try again. window.setTimeout(() => getSessionNumber(callback), 200); return; } return sessionNumber; } ``` ### Timestamp_micros The **Timestamp_micros** represents the exact time of an event, measured in microseconds. This value is essential for accurate tracking and attribution of user actions across systems, ensuring precise event timing. The value of **Timestamp_micros** should be generated right after the user completes a form on the website. After form submission, the timestamp should be recorded and stored in the CRM for further analysis and reporting. ## Description of variables for data transfer ### URL Parametrs | | Value | Comment | | -------- | -------- | -------- | | API Secret | 8ArRy4ikS9qr1CmbA8jqVw | API Secret | | measurement_id| G-8P87N374QH | ID stream GA4| ### JSON | Parameter | Value Type | Example | Comment| | -------- | -------- | --- | -------- | | client_id | text | 123123.12323 | Client Id from GA (required) | | session_id | int | 123123 | Session Id from GA (required | | timestamp_micros | text | 123123123 | | | event[{}] | text | event_booking | Afters succesfull meeting booking | When client succesfully book the meeting slot a request should be made using the following [configuration](https://ga-dev-tools.google/ga4/event-builder/?p=2&d=0&f=0&c=custom_event&j=event_booking&n=644846202.1727163978&k=8ArRy4ikS9qr1CmbA8jqVw&i=G-8P87N374QH&e=1727270795972000&m=W10&a=W3sibmFtZSI6Im1lZXRpbmdfaWQiLCJ0eXBlIjoic3RyaW5nIiwidmFsdWUiOiJNXzEyMzQ1In0seyJuYW1lIjoibWVldGluZ190aW1lIiwidHlwZSI6InN0cmluZyIsInZhbHVlIjoiMjAyMy0xMi0xOFQxMDowMDowMCJ9LHsibmFtZSI6Im1lZXRpbmdfc3RhdHVzIiwidHlwZSI6InN0cmluZyIsInZhbHVlIjoiY29uZmlybWVkIn0seyJuYW1lIjoic2Vzc2lvbl9pZCIsInR5cGUiOiJudW1iZXIiLCJ2YWx1ZSI6IjE3MjcxNzUwNDIifV0): ``` POST /mp/collect?api_secret=8ArRy4ikS9qr1CmbA8jqVw HTTP/1.1 HTTP/1.1 HOST: www.google-analytics.com Content-Type: application/json ``` **Important!** Only status changes that include a client_id should be transmitted. **Code Implementation (example):** ``` { "client_id": "644846202.1727163978", "timestamp_micros": "1727270795972000", "non_personalized_ads": false, "events": [ { "name": "event_booking", "params": { "meeting_id": "M_12345", "meeting_time": "2023-12-18T10:00:00", "meeting_status": "confirmed", "session_id": 1727175042 } } ] } ``` ## Suggestions To automate the process of transmitting booking meeting data from HubSpot to Google Analytics 4 using the Measurement Protocol, webhooks can be integrated with HubSpot workflows. This will allow you to send real-time data when specific events occur, such as a change in booking status. [Here](https://knowledge.hubspot.com/workflows/how-do-i-use-webhooks-with-hubspot-workflows?_gl=1*1mr3zrs*_gcl_au*NDgwMDY3MDE0LjE3MjcyNjExMjI.*_ga*MTIwNjk1MzEzNi4xNzI3MjYxMDc5*_ga_LXTM6CQ0XK*MTcyNzI2MTA3OS4xLjEuMTcyNzI2MTI4MS41NS4wLjA.) documentation that can be usefull --- ## [<span class="octicon octicon-link" style="color: rgb(0, 0, 0); vertical-align: middle; visibility: hidden;"></span>](#Contact-for-Questions "Contact-for-Questions")Contact for Questions <div class="alert alert-info" style="font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, &quot;Helvetica Neue&quot;, Helvetica, Roboto, Arial, sans-serif; font-size: 16px; letter-spacing: 0.35px; margin-bottom: 0px !important;"> <span style="font-weight: 700;">For all the questions regarding the measurement plan please reach out to:</span> Muslim Karaiev - [muslim.karaiev@newage.agency](mailto:muslim.karaiev@newage.agency) Valeriia Mishcherikova - [valeriia.mishcherikova@newage.agency](mailto:valeriia.mishcherikova@newage.agency) </div>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully