What we think

How to split traffic in Google Analytics by local time of day using Google Tag Manager

In Google Analytics, you can analyse data based on time of day. The time of day is based on the time zone you have specified in your admin area. This is fine if 95%+ of your traffic comes from people in the same time zone as you, but what if you have customers across the US, or a large European audience, including UK and Ireland?

You can see time-of-day trends using the “hourly” option in the audience overview report.

Knowing about a 1pm traffic peak in your local time (i.e. whatever is set in your views settings) is good in some regards, as it might let you know you need more people manning the phones at 1pm. Assuming your office is (probably) in one time zone and you don’t care if customers are calling at 3am their time, having more staff at the phones at 3am won’t help in that regard.

If you’re using a custom report or the API to export this data, the dimension you will need is “Hour” and you can analyse this behaviour however you’d like. For example, you can create a graph that shows the most popular times of day:

Hourly website traffic graph

Or group these together into “Office Hours” and “Out of Office” using some Excel know-how (TIP: It involves adding a “Category” column and a pivot table).

Office hours and out of office graph

Why should I measure local time in Google Analytics?

Measuring local time is great, but what about how people act at their local time? It might not impact what you do at 3pm in your office, but knowing that 90% of users from around the world read your content on their lunch break can have an impact on how you structure your content or create your CTAs.

If their lunch break is the middle of the night for you, Google Analytics is not reporting it accurately, and you may never know that “lunchtime reading” is what everyone is doing. Not unless you do some exports by country or city, match it to a time zone, transpose all the data… and that’s a lot of work.

I’d rather just Google Analytics show me a graph so I can see if there’s a pattern without having to do heavy lifting.

Google Analytics local time graph

How do I measure local time in Google Analytics?

I measure local time using a custom dimension, via Google Tag Manager. I split it into three categories: Office Hours, Non-Office Hours and Lunch, but it is possible to do this for every hour of the day if you’d prefer.

STEP 1) Create a Custom Dimension in Google Analytics

To create a custom dimension, go to Admin>Custom Definitions>Custom Dimensions. Click “Add New Custom Dimension”. Give it a name (e.g. “Time of Day” or “Local Time). Set the Scope to “Hit” and mark it as active. Take a note of the dimension index (below the index in 5).

Google Analytics custom dimension

Google Analytics custom dimension name

Step 2) Create a variable in GTM called “Local Time”

Go to variables>New Variable and choose the variable type “Custom Javascript”. Paste in the code:

function() {

  var now = new Date();

  return now.getHours();

}

And save it.

Step 2a) Create a Variable called “In or out of office” (optional)

Go to variables>New Variable and choose the Variable type “Lookup table”. Choose the lookup variable “Local Time” and create a look-up table to define which hours you want as Office Hours (e.g. 9-11 and 14-17) and Lunchtime (e.g. 12-13). You can modify this as it suits you. Finally, set a default value to “Non-Office Hours”. Save this.

In or out of office Lookup table

Step 3) Associate your variable with your Google Analytics tag

Edit your Google Analytics pageview tag (or variable if you are using one). Under “More Settings”, expand “Custom Dimensions”. Fill in “Index” with the custom dimension variable that Google Analytics gave you when you set one up. In “Dimension Value”, choose the dimension you created: {{In or Out of Office}} or {{Local Time}}, whichever suits you.

Editing your Google Analytics pageview tag

Save your tag and publish the new container.

You can then build a custom report in Google Analytics to analyse this data.

Custom report in Google Analytics

If you have any trouble analysing this data or building this report, feel free to get in touch.

Related posts