Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I verify that a Google Tag Manager id is valid?

It looks like, from inspection, that the form of a Google Tag Manager id is "GTM-XXXXXX" where the x's are [A-Z]|d, is this accurate? I need to verify whether the id's being submitted to a CMS are valid.

like image 820
KevDog Avatar asked Sep 11 '25 06:09

KevDog


2 Answers

I've just wrote this one for our framework:

/^GTM-[A-Z0-9]{1,7}$/

Tested with 25 GTM container IDs in our account, all passed validation. You can try this expression out here.

like image 66
Adambean Avatar answered Sep 13 '25 06:09

Adambean


The format varies. I see various combinations of numbers and letters, some just letters, none just numbers, most 6 characters, and few with 4 characters. There's no clear pattern. They begin with either a letter or number, and end with a letter or number.

like image 35
nyuen Avatar answered Sep 13 '25 05:09

nyuen