简体   繁体   English

如何使用 JavaScript 提取电子邮件地址域?

[英]How to extract email address domain using JavaScript?

I would like to pass the contents of a form field as a event label to Google Analytics.我想将表单字段的内容作为事件标签传递给 Google Analytics。

However, I do not want to pass any personally identifiable information due to it being against Google's terms.但是,我不想传递任何个人身份信息,因为它违反了 Google 的条款。

I am currently using this code to extract the appropriate form field's value, however, how would I tailor it so I only get the latter part of the email address.我目前正在使用此代码来提取适当的表单字段的值,但是,我将如何定制它,以便我只能获取电子邮件地址的后半部分。

@icloud.com | @icloud.com | @btinternet.com | @btinternet.com | @xxxxxx.com etc?? @xxxxxx.com 等??

Thank you very much in advance.非常感谢您提前。

function() {
  var field = {{Form Element}}.querySelector('#email_address');
  return field ? field.value : undefined;
}

Any part of a user's email address can be personally identifying.用户电子邮件地址的任何部分都可以识别个人身份。 Although most people use email providers such as GMail, not all do.尽管大多数人使用 GMail 等电子邮件提供商,但并非所有人都这样做。

For instance, my email address is of the form email@firstnamelastname.tld , which means if you extracted the part after the @ sign you would still have my name there, which is personally identifying, which is against Google's terms.例如,我的电子邮件地址的格式为email@firstnamelastname.tld ,这意味着如果您提取@符号后的部分,您仍然会在那里保留我的名字,这是个人身份识别,这违反了 Google 的条款。

So the answer to this question is: don't do it .所以这个问题的答案是:不要这样做

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

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