简体   繁体   English

Linux 桌面用户代理正则表达式?

[英]Linux Desktop User Agent Regular Expression?

Does anyone know a good catch-all for Linux user agents?有谁知道 Linux 用户代理的一个很好的包罗万象? I have a scenario where I need to block Google Tag Manager tags from firing for Linux users.我有一个场景,我需要阻止 Google 跟踪代码管理器标签为 Linux 用户触发。 The goal is to prevent Linux data from reaching Google Analytics.目标是防止 Linux 数据到达 Google Analytics。 I don't want to impact Android users.我不想影响 Android 用户。 I expect I could do something where I match on Linux while doing a negative lookahead for Android, but I'm not sure if I will be missing some scenarios.我希望我可以在匹配 Linux 的地方做一些事情,同时对 Android 进行负面前瞻,但我不确定我是否会遗漏一些场景。 Any recommendations?有什么建议吗?

No need to limit yourself to a trigger based on a built-in variable.无需将自己局限于基于内置变量的触发器。 In this case, you want to actually have a CJS variable that would take into account not just the useragent, but the viewport too to make sure mobile resolutions would be exceptions from any useragent-based logic you have.在这种情况下,您实际上想要一个 CJS 变量,它不仅要考虑用户代理,还要考虑视口,以确保移动分辨率是您拥有的任何基于用户代理的逻辑的例外。

And since we're on JS level now, no need to try and fit all logic in one regex.由于我们现在处于 JS 级别,因此无需尝试将所有逻辑都放在一个正则表达式中。

As a precaution, you can build a user-agent report in GA comparing a time period before your change to the time period after your change.作为预防措施,您可以在 GA 中构建用户代理报告,比较更改前的时间段和更改后的时间段。 GA will graciously highlight losers so you'll see what adjustments to your logic are to be had. GA 会亲切地突出显示失败者,以便您了解需要对您的逻辑进行哪些调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM