It's not 100 percent clear to me that the Google Analytics UA Numbers are always 6 digits, a dash, and 2 digits as Google often mentions in their documentation. There are frequent counter-examples that use fewer than 6 for the account portion and 1-4 for the profile. All of the examples always show numbers but it's not even clear that they can't be letters.
Does anyone know if Google has published a regex that exactly matches allowable UA Numbers? I'm adding this feature to the admin console of an application I work on and would like to validate the user input.
Perhaps there is no fixed range of digits. 6 digits for the account number would limit Google to 1,000,000 users. I'm sure Google aims higher than that. This Google Analytics FAQ item shows UA-xxxxxxx-y
as a sample account number (7 + 1 digits). I would presume that only the UA and dashes are fixed and that the number of digits expands as the number of users and profiles grows. E.g. to allow 4 to 10 digits for the user and 1 to 4 digits for the profile you could use this Perl-style regex:
\bUA-\d{4,10}-\d{1,4}\b
If it has to work with the limited Google Analytics regex syntax try this:
UA-[0-9]+-[0-9]+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With