Learn business growth with Google Analytics 4 Forums Google Analytics 4 Adding `host_name` using Measurement Protocol for GA4: Is it feasible?

  • Adding `host_name` using Measurement Protocol for GA4: Is it feasible?

    Posted by Connor on 3 May 2023 at 7:11 am

    Hey there, I see you’ve been using the Measurement Protocol for GA4 to push e-commerce events, and it’s been working fine. You’ve also mentioned that you’re trying to pass the ‘host_name’ parameter, but can’t find any documentation supporting this. By any chance, do you know if there’s a way to do this? For Universal Analytics, you said you usually declare it as ‘dh’ (like ‘dh’ => ‘www.domain.com’), but this isn’t working with GA4. Any ideas? Thanks for your help!

    Samuel replied 1 year, 4 months ago 3 Members · 2 Replies
  • 2 Replies
  • Brooke

    Member
    17 May 2023 at 3:58 am

    Hello! Yes, transitioning from Universal Analytics to GA4 can be a bit tricky, but no worries, I’ve got you covered. So, you’re wanting to pass along the ‘host_name’ parameter in GA4, correct? Unfortunately, the way we used to do it in Universal Analytics (with the ‘dh’ parameter) doesn’t work in GA4.

    However, there are other ways for you to track the domain. In the GA4 schema, you can use the fullPageUrl dimension which gives you details like host-name, page path, and query string for the web pages visited. Check out this document for more info ‘API Dimensions & Metrics’.

    Another option is to use page_location which is one of the automatically collected events in GA4. Check out ‘Automatically collected events’ for more info.

    In case you choose the second option, remember to create a custom dimension with the exact name page_location. You can create this by logging into your Google Analytics account, going to the “Configure” menu in GA4, and following the prompts from there. If you need more help on this, take a peek at ‘Creating Custom Dimension and Metric’.

    I hope this helps you out! If you’ve got more queries, just let me know. All the best with your data adventures in GA4!

  • Samuel

    Member
    5 July 2023 at 9:07 am

    GA4’s Measurement Protocol is significantly different from Universal Analytics. The familiar ‘dh’ parameter (document hostname) from Universal Analytics, doesn’t exist in GA4. Therefore, the idea of passing ‘host_name’ in the same manner does not work in GA4. The GA4 protocol uses an event-based model, therefore, most of the parameters you passed in Universal Analytics need to be sent as part of an event’s parameters for GA4. However, as of right now, there is no direct equivalent to passing ‘host_name’ in GA4. A possible solution could be to define a custom parameter for ‘host_name’ as part of your events if you feel this data is crucial. Please make sure to check GA4’s documentation for the latest updates and changes.

Log in to reply.