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.
To know how Google Analytics formats your organization’s name. If you’re not sure, we’ll help you find this in this guide.
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.
Navigate to custom reports: Customization -> Custom Reports. Then click the
+ New Custom Report button.
Give your custom report a title
Set the type to “Flat Table”
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).
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.
+ add filter button and add an Organization filter:
Make sure you change
Regex (as in the image).
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.
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.
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: | .
Paste the entire regex string into the empty box to the right of
Once you’ve set up your filter, click save. Move on to Step 8 to learn more about using the report.
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=”.
Once you have this, return to step 6.
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.