Setting Up Google Analytics For Your Bitbucket Repositories

One cool feature of Bitbucket is the ability to track traffic to your repositories using Google Analytics. Setting it up is simple, but there are a few subtle tricks. Here’s how to do it.

  1. From your main Google Analytics screen, click “Add Website Profile” at the bottom of the screen.
  2. If this is the first repository you’ve setup, select the option to add a profile for a new domain. Once you’ve done this for one of your repositories you can use the existing domain option.
  3. In the URL field, enter “”.it won’t let you enter the full URL of your repository here.
  4. Click “Finish”, which should take you back to the main Google Analytics screen.
  5. Find your analytics key for Bitbucket (i.e. UA-123456-7) and copy it.
  6. Go to the “Admin” page of your repository and paste the analytics key in the appropriate field.
  7. Head back to Google Analytics and click “Edit” on your newly created profile to bring up its settings.
  8. Under the “Main Website Profile” click “Edit” and paste the full URL of the repository in the “Website URL” field.
  9. It might take a few minutes, but the status of the tracking code should change from “Tracking Unknown” to “Waiting for Data”, and eventually to “Receiving Data”.

Now you are able to have some valuable insight into traffic reaching your repositories!

in Blog | 227 Words