Look up traffic for your organization's content

Google Analytics offers more detail about traffic to your content.

Overview

You can use Google Analytics to get a report that shows how much traffic all your organization’s content gets. While you can also see all your content’s pageviews in the CMS, Google Analytics offers more detail and allows you to filter by date.

You’ll need:

  • To know how Google Analytics formats your organization’s name. If you’re not sure, we’ll help you find this in this guide.

Getting started

Log in to Google Analytics. Check in the upper left to make sure that you’re in the Mass.gov (Drupal) property and the “All Public Traffic” view. If you’re not, you can click the drop-down arrow to switch.

Step 1: Create a custom report

Navigate to custom reports: Customization -> Custom Reports. Then click the + New Custom Report button.

Step 2: Set up the custom report

  • Give your custom report a title

  • Set the type to “Flat Table”

Step 3: Add your dimensions

We want to add 2 dimensions to this report: Page and Organization. To do this, click the + add dimension button and begin typing. When the dimension you’re looking for appears, click it (or scroll to it and click it).

Step 4: Add your metrics

Since you want to learn about your organization’s traffic, you should add pageviews and/or unique pageviews as metrics. To do this, click the + add metric button and begin typing. You’ll have to scroll to find them; they don’t appear right at the top.

Pageviews is the total number of times a page is loaded. Unique pageview is the number of sessions a page appeared in. Learn more about the difference.

Step 5: Set up the filter

Click the + add filter button and add an Organization filter:

Make sure you change Exact to Regex (as in the image).

Note: You can save your report right now. That way, if you have to come back later, you can simply re-open it from the Custom Reports menu.

Step 6: If you know how your organization is listed in Google Analytics: Create the regular expression string (regex)

Next, we want to filter out all traffic that’s not your organization’s. This is the tricky part, though. In January 2019, the Mass.gov team changed the way organization names were formatted in the site’s metadata. The reason this matters for you is that we need to create a filter that includes both formats.

If you already know what your organization’s name was before the January update, you can figure out the rest without doing any detective work. All you have to do is remove the hyphens. Or, if you know the un-hyphenated version, add them.

Examples:

division-of-fisheries-and-wildlife ➜ divisionoffisheriesandwildlife

department-of-unemployment-assistance ➜ departmentofunemploymentassistance

If you don’t know your organization’s name in Google Analytics, move to step 7.

Regular expression syntax

To create the filter that Google Analytics will use to look up your organization’s traffic, connect the 2 organization name formats with a vertical pipe: | .

Examples:

division-of-fisheries-and-wildlife|divisionoffisheriesandwildlife

department-of-unemployment-assistance|departmentofunemploymentassistance

Paste the entire regex string into the empty box to the right of Regex

Once you’ve set up your filter, click save. Move on to Step 8 to learn more about using the report.

Step 7: If you don’t know how your organization is listed in Google Analytics: Check the metadata

To find out what your organization is called in Google Analytics, open any one of your pages in a new browser tab. Right click anywhere on the page and select “view page source” or “view source.” (The exact wording depends on which browser you are using).

This will open the HTML code that generated your page. It might look overwhelming at first, but we just need whatever is listed in the line beginning with <meta name="mg_organization">. To find this line, use control + F (on a PC) or command + F (on a Mac) and search for <meta name="mg_organization."

You’ll find your organization listed in this line after content=”.

Important: You might find more than 1 organization, e.g.: digitalservices,executiveofficeoftechnologyservicesandsecurity. You only need yours – not your parent’s.

Once you have this, return to step 6.

Step 8: Using your custom report

Once you’ve saved the report, it will always be available under the Custom Reports menu. You can change the date range using the selector in the upper right.

You can also export the data using the button above the date picker.

Was this article helpful?

Tell us what you think button