使用Google跟踪代码管理器从网址中删除查询字符串 [英] Removing Query Strings from the URL Using Google Tag Manager

查看:55
本文介绍了使用Google跟踪代码管理器从网址中删除查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过从网址中删除查询字符串来整理Google Analytics(分析)中的分析,但这已分为三个要求;

I'm trying to tidy up the analysis in Google Analytics by removing query strings from the URL, but this has split into three requirements;

  1. 我要删除查询字符串以使其不显示在Google Analytics(分析)分析中.
  2. 广告系列UTM仍然需要工作.
  3. 从打击GA中停止在UTM中收集的所有PII.

我发现了许多可以执行任务3的JavaScript方法(如下所示),但是我不知道此实现是否会影响任务1和2.

I've found a number of JavaScript methods (attached below) that will do task 3, but I don't know whether this implementation will affect tasks 1 and 2.

这引起了我的疑问;

JavaScript方法会阻止所有查询字符串完全击中GA,从而破坏我的广告系列UTM吗?

感谢您的帮助!

下面附有JavaScript

function() {

var params = ['name', 'email'];
var a = document.createElement('a');
var param,
  qps,
  iop,
  ioe
  i;

a.href = {{Page URL}};

if (a.search) {

qps = '&' + a.search.replace('?', '') + '&';

for (i = 0; i < params.length; i++) {

  param = params[i];
  iop = qps.indexOf('&' + param + '=');

  if(iop > -1) {

    ioe = qps.indexOf('&', iop + 1);
    qps = qps.slice(0, iop) + qps.slice(ioe, qps.length);

  }

}

a.search = qps.slice(1, qps.length - 1);

}
 return a.href;
}

推荐答案

如果使用类似( window.location = {{clean URL}} ),自然会导致重新加载.

If you update the page location in the DOM with the result of a function like this (window.location={{clean URL}}) you would naturally cause a lot of problems by causing reloading.

如果您使用此函数的结果来设置与页面和引荐来源网址相关的UA参数,则它不会影响与匹配中与那些参数无关的UA.例如,您可能希望清除 page 字段,而不仅仅是页面匹配:

If you use the result of this function to set UA parameters relating to page and referrer, then it affects nothing that isn't related to those parameters in the hits. For example, you would want to clean the page field which is not just on page hits:

类似utm参数的内容是从常规DOM/BOM(例如 window.location )和

Things like utm parameters are extracted from normal DOM/BOM (for example window.location) and sent as separate parameters and are not calculated from page related parameters later on the server side unless you are doing extraction yourself in Analytic's custom filters.

这篇关于使用Google跟踪代码管理器从网址中删除查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆