Easily get your Google Analytics account ID

Ok I’m kinda bummed: why doesn’t Google just add a field to Google Analytics that gives you the account ID, instead of telling people who want to track Google sites to extract the account ID from the javascript code…

Well I’m here to make it easier for you people. Paste the code that Google gave you into the textarea below, and click this button:

Now Google Analytics team, if you’re reading this, this isn’t hard, here’s the code, feel free to use it:

<script type="text/javascript" charset="utf-8">
function get_UA() {
txt = document.getElementById('scripttag').value;
var matches = txt.match(/(UA-[\d-]+)/);
if (matches[1]) {
alert(matches[1]);
}
}
</script>
<textarea name="script" cols="40" id="scripttag" rows="10"></textarea>
<button onclick="javascript:get_UA();">get account id</button>[/code]

That's a whole lot easier than telling people how to extract their UA code, isn't it?

Tags:


Yoast.com runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

19 Responses

  1. Jason LengstorfBy Jason Lengstorf on 23 January, 2009

    On my Google Analytics, the UA is right next to the name of each site before I view the reports. I don’t know what happens if you only have one site, but I don’t think this is an issue for people with multiple sites being tracked, at least…

    • Joost de ValkBy Joost de Valk on 23 January, 2009

      True, was pointed out on Twitter as well, but Google is telling people to extract it from the code, that’s just plain lame to me…

  2. John StevensBy John Stevens on 23 January, 2009

    Joost, has you script anything to do with the warning at the bottom of this page?
    Warning: fsockopen() [function.fsockopen]: unable to connect to tr.im:80 (Connection timed out) in /nfs/c01/h04/mnt/43978/domains/yoast.com/html/wp-includes/class-snoopy.php on line 1142

    • Joost de ValkBy Joost de Valk on 23 January, 2009

      Nope, that’s tweetbacks causing issues…

  3. Mike BelascoBy Mike Belasco on 23 January, 2009

    Instead of pasting in the code, why not ask for a URL and pull it from the site? That would be waaaay easier and quicker. Not that I don’t appreciate what you have done here ;)

    • Joost de ValkBy Joost de Valk on 23 January, 2009

      Not quite sure I get what you mean there… The code isn’t on the site yet, so no way to get it from there, I guess? :)

  4. MartijnBy Martijn on 23 January, 2009

    Isnt that one available from the profile overview nowadays?

  5. Mike BelascoBy Mike Belasco on 23 January, 2009

    Sorry Joost,
    I misunderstood. I thought you the code was on site already and you needed to get the ID for some reason.

  6. umaxtuBy umaxtu on 26 January, 2009

    uh guys it’s really easy to get ur account id
    in you analytics dashboard just click on analytics settings and there is your account ID

  7. Marco CiliaBy Marco Cilia on 26 January, 2009

    why not a simple line to paste in the url during the visit? :)

    javascript:prompt(“your account”, pageTracker._getAccount());void(0);

  8. LynneBy Lynne on 25 March, 2009

    I did what you said ( copy and paste and I still don’t know where my ua code or account or what ever is. Please help me I have three web sites and none of them have it. asklynne.com, petryandprose.com and writersandartists.com Thank you for any help you can give me. Lynne

  9. LynneBy Lynne on 25 March, 2009

    I did what you said ( copy and paste and I still don’t know where my ua code or account or what ever is. Please help me I have three web sites and none of them have it. asklynne.com, poetryandprose.com and writersandartists.com Thank you for any help you can give me. Lynne

  10. StacyBy Stacy on 30 September, 2009

    What’s ironic is that the analytical ID is directly next to your website in your profile, but
    it doesn’t indicate that its your ID. THank for sharing and creating this!! After I posted my code,
    the ID matched exactly on my Analytics profile.

Trackbacks