Swift Software Group

Setup Google Analytics for a Bitbucket repository

The idea is to create a new Google Analytics property for Bitbucket and then have a separate Google Analytics profiles for each repository. That way I end up with one profile per repository neatly grouped under the Bitbucket property. In the profiles, I also use filters to include only the traffic for the corresponding repository.

This post is about myself setting up Google Analytics for our AVBlocks-Samples repository, so in the steps below I use the “AVBlocks-Samples” name and the corresponding URL. Needless to say, when going through the steps, you will use the name and URL of your own Bitbucket repo. OK, here it goes:

Create a new Google Analytics property called Bitbucket

  1. Go to Google Analytics and login into your account.
  2. Click on the Admin link at the top right corner.
  3. Click on the property drop-down list and then select the New Property at the bottom.
  4. Select “Classic Analytics” for tracking method.
  5. Under Website Name, type “Bitbucket”.
  6. Under Web Site URL, select “https://” and type “bitbucket.org”.
  7. Click [Get Tracking ID]

2013-08-19-19_30_38-google-analytics 2013-08-19-19_52_18-google-analytics

Add the Tracking ID to the Bitbucket repository

Google Analytics will generate a new tracking ID for you, something that looks like “UA-123456-78″.

  1. Copy the Tracking ID that Google generated
  2. Go to the repository admin page on Bitbucket
  3. Paste the Tracking ID into the “Google Analytics key” field.

2013-08-19-19_55_54-avblocks-samples-bitbucket

## Update the Google Analytics profile

  1. Go back to Google Analytics admin page
  2. Select “Bitbucket” for property
  3. Select “All Web Site Data” for profile
  4. Click “View Settings”
  5. Update the Website’s URL with the full URL of your bitbucket repository.
  6. In my case I put “https://” and “bitbucket.org/primosoftware/avblocks-samples”.
  7. If you plan to have multiple repo profiles under the Bitbucket property, I recommend changing the View name to something other than “All Web Site Data”. I my case, I named my property “AVBlocks-Samples”.
  8. Click Apply.

2013-08-19-20_06_28-google-analytics 2013-08-19-20_12_10-google-analytics 2013-08-22-06_27_20-google-analytics

Setup a profile filter

  1. Go back to Google Analytics admin page
  2. Select “Bitbucket” for property
  3. Select “AVBlocks-Samples” for profile
  4. Click “View Settings”
  5. Click “Filters” and then on the +New Filter button.
  6. Type “AVBlocks-Samples” for Filter Name
  7. Select “Predefined filter” for Filter Type
  8. Select “include only”, “traffic to subdirectories”, “that begin with”
  9. Type “/primosoftware/avblocks-samples/” for Subdirectory
  10. Select “No” for Case Sensitive
  11. Click Save

2013-08-22-07_00_25-google-analytics 2013-08-22-07_15_04-google-analytics 2013-08-22-07_15_47-google-analytics