wordpressgoogle-analyticscross-domain

`?_gl` query parameter is added to my URL links to my subdomain - how to remove it?


I'm using Wordpress and on my site I have link to my subdomain. When I click the link it adds query parameter _gl. I don't want it. I want my link to look clean.

How to turn it off?

When I click link it looks like:

https://mysubdomain.mydomain.org/?_gl=1*...*_ga*...*_ga_....*....

where ... are some random changing code.


Solution

  • So I figured out. _gl parameter was added because of Google Analytics 4. And in my Wordpress it was enabled by plugin Site Kit by Google.

    1. simple solution to remove it, one can just disable whole Site Kit plugin.
      DON'T FORGET TO Clear Post Cache in your Wordpress wp-admin console. Just cos I did't I spent another hour figuring why it didn't disappeared cos probably bloody CDN remembered scripts...

    Anyway this means your Google Analytics will not work at all on your site. Which might not be an ideal solution.

    1. better solution I found out I can keep Site Kit enabled and just add following Javascript code:

      window.addEventListener("load", function() {     
        if (window.google_tag_data && indow.google_tag_data.gl.decorators){
          window.google_tag_data.gl.decorators = [];
        }
       });
      

    (Again don't forget to Celar Post Cache.)

    You can add javascript easily for example using plugin Simple Custom CSS and JS By SilkyPress.com. I did set javascript to be added in <footer>.

    Now what you lost by removing this _gl parameter? You lost cross-domain analytics. Meaning if one person comes from your domain to your subdomain he will be counted twice... Boo hoo. I don't care... Although I understand it's cool feature, not worthy for me to have ugly URL...

    1. There might be even better solution to remove it in your subdomain so cross domain analysis would even work... I didn't try this solution cos I did not need it and it was more code. But here it is: Cross-Domain tracking with clean urls - by David Vallejo

    Also I would be happy if someone would figure out how to turn _gl query parameter off directly in Google Analytics 4 settings (https://analytics.google.com/)...

    I already tried in Admin->Data Streams->click your data stream->Configure tag settings:

    And note somewhere I saw people were guiding how to remove it from reporting. That is useless for me I want to remove it from my URL link so link looks nice...