Learn business growth with Google Analytics 4 Forums Google Analytics 4 Modifying GA4 URLs to Exclude Guid in Google Analytics 4

  • Modifying GA4 URLs to Exclude Guid in Google Analytics 4

    Posted by Presley on 3 October 2022 at 3:07 am

    So we’re using Universal Analytics and now switching to Google Analytics 4. With Google Tag Manager, we manage five websites under a single domain. One of these sites has a guid in its URL. With UA, we set up a filter to remove this so we wouldn’t overstep the daily URL limit. We went from a long URL to a shorter format.

    The problem now is that GA4 doesn’t allow advanced filtering yet. This leads us to exceed the daily limit and the values appear as ‘(Other)’. Is there a workaround to rewrite URLs for GA4?

    In an update, we crafted a new GA4 for that specific site by tagging a variable that alters the ‘page_location’ field via JavaScript as BNazaruk recommended. Check out the images that show an example of how a URL is split and how it returns to override the ‘page_location’ field.

    Zoe replied 1 year, 3 months ago 3 Members · 2 Replies
  • 2 Replies
  • Aiden

    Member
    20 October 2022 at 6:37 pm

    So, you’re switching from Universal Analytics to Google Analytics 4 and got stuck because of the inability to filter URLs like you used to. No worries, we’ve got a few options to tackle this.

    First off, consider removing sensitive information, like a guid, from your URL. This is viewed as a best practice and not only affects GA but any pixel you install. This also has implications for your backend access logs that would contain these IDs. Correcting this would eliminate the need to replace it in analytics.

    Next up, don’t forget Google Tag Manager (GTM) can be a very handy tool here. It can help override the location and path dimensions quite smoothly. You’d do this using three Custom JavaScript (CJS) variables. Two will take the document.location.href, sanitize it according to your needs and return. The third one will process the referrer in a similar way. The only trick here is you’ll have to do this override for every GA4 tag because Google doesn’t allow us to use a config variable like we used to in UA tags.

    Last but not least, there’s the option to replace the data during the Extraction, Transformation, and Load (ETL) process if you’re using another system for analysis. However, this doesn’t take away the sensitive data in GA, which could be a problem depending on your need to sanitize the data.

    Hopefully, one of these options would help you out!

  • Zoe

    Member
    12 November 2022 at 1:25 pm

    Yes, there is a workaround to rewrite URLs for GA4 to avoid exceeding the daily limit. You can create a new GA4 for the specific site and use a variable in Google Tag Manager that modifies the ‘page_location’ field. You accomplish this modification through JavaScript. By manipulating the URL in this way, you can reduce its size and prevent it from overstepping the daily limit imposed in GA4 since it does not yet allow advanced filtering. This method allows you to manage URL lengths effectively, ensuring they are captured correctly in GA4.

Log in to reply.