Set a custom alert in Google Analytics that emails you when daily sessions fall far below the same day last week, and check the tracking code after every theme update, plugin change or redesign.

A flat line nobody saw

Someone opens Analytics to prepare a report and finds a flat line along the bottom of the chart: no visits at all, for seven weeks.

The site worked the whole time. Customers called, forms arrived, orders came in. Analytics simply stopped hearing about any of it.

Usually the tracking code, the small script on every page that reports each visit to Google, has gone missing during a change to the site.

Those weeks cannot be recovered. Analytics records only what it receives at the time.

How the code goes missing

The first is the most common on WordPress sites. Code pasted directly into a theme's header file disappears when the theme updates, because the update replaces every theme file with the developer's new version.

Why it goes unnoticed

Few small businesses open Analytics more than once a month, and many open it only when they need a figure for something.

The site gives no sign. Pages load, forms send, and nothing on screen says that visits have stopped being counted.

By the time anyone looks, the gap is weeks long, and if it covers a busy season or a campaign, the comparison you most wanted is gone for good.

Custom alerts

Universal Analytics can watch for this on your behalf. A custom alert checks a figure every day, week or month and sends an email when a condition you set is met.

Alerts are created in the Admin section, under the view, and each applies only to that view. They cost nothing and take a few minutes to set up.

The alert to set first

Create a daily alert on sessions for all traffic, triggered when sessions fall by more than about half compared with the same day in the previous week.

Comparing with the same weekday avoids most false alarms, since a quiet Sunday is measured against the last quiet Sunday rather than against a busy Friday.

Add a second alert for sessions below a very small number, such as five in a day, which catches tracking that has stopped completely.

Send both to two people, so a holiday or an overflowing inbox does not leave them unread.

An alert for the opposite fault

Tracking can also break by appearing twice: a plugin and the theme both adding the code, or the code installed both directly and through Google Tag Manager. Every page view is then counted twice.

The giveaway is a bounce rate that suddenly drops close to zero, because every visit now looks like at least two pages.

An alert for bounce rate falling below anything your site has ever recorded catches this the morning after it starts.

A worked example

A small-town arts council runs a website listing exhibitions, workshops and events for its member groups, and reports its website visits each year to members and funders.

In April a volunteer updated the site's theme, which had been showing an update notice for months. The update went smoothly, and the site looked exactly the same.

Years earlier, another volunteer had pasted the tracking code into the theme's header file. The update replaced that file, and from that afternoon Analytics recorded nothing.

Seven weeks later the coordinator sat down to prepare the year's figures and found a flat line straight through the spring exhibition, the busiest event of the season.

The code went back in through a method that survives theme updates, the gap was marked with an annotation, and two alerts now go to the coordinator and the treasurer.

The annual report explains the missing weeks instead of leaving a hole nobody can account for.

Keep the code out of the theme's files

On WordPress, the tracking code belongs in a child theme or a small plugin, or in Google Tag Manager installed the same way, not pasted into the main theme's files.

A child theme keeps your changes separate from the files the theme's developer updates. A plugin keeps tracking independent of the theme altogether, so even a new theme leaves it in place.

Whoever maintains the site should know where the code lives, and should write it down where the next person will find it.

Check after every change

Make checking the code part of every update, plugin change and launch, in the same breath as testing the contact form.

The quickest check is the Real-Time report. Open the site on your phone, over mobile data if your office connection is filtered out, and watch for your own visit to appear.

Searching the page source for your tracking ID, which begins with UA-, confirms the code is present. Google's Tag Assistant, a free extension for Chrome, shows whether it is working.

Annotate any gap

If a gap has already happened, add an annotation in Analytics where it began and where it ended, saying what caused it.

Otherwise anyone comparing this year with next year will read the missing weeks as a collapse in interest.

Where the gap matters, the business's own records can partly fill it: form submissions, orders, bookings and phone calls.

The counter-case

A business that never opens Analytics will not miss a few weeks of it, although that is a reason to start reading the figures rather than to skip the alert.

Alerts also raise false alarms after holidays or unusually quiet weeks. A business that hates the noise can use a weekly alert instead of a daily one.

For anyone who relies on the figures at all, set the alert, and check the code after every change to the site.

Before the next update

  1. Look at sessions for the past six months.
  2. Annotate any gaps you find.
  3. Create a daily alert for a sharp fall.
  4. Add an alert for sessions near zero.
  5. Send both to two people.
  6. Move the code out of the theme's files.
  7. Check Real-Time after every site change.

Step six is what prevents the next gap. Alerts tell you the morning after something breaks; code kept outside the theme stops the most common break from happening at all.

Another enquiry route Analytics misses by default is covered in clicks on email addresses that Analytics never sees.


Frequently asked questions

Why would Analytics suddenly record nothing?

Usually the tracking code was removed by a change to the site: a theme update, a new theme, a removed plugin or a redesign launched without it.

What is a custom alert in Analytics?

A rule in Universal Analytics that checks a figure each day, week or month and emails you when a condition you set is met, such as sessions falling sharply.

Which alert should I set first?

A daily alert for sessions falling by more than about half against the same day last week, plus one for sessions near zero, sent to two people.

Can I recover the missing data?

No. Analytics records only what it receives at the time. Annotate the gap, and use your own records of forms, orders and calls to partly fill it.

Where should the tracking code live?

Outside the main theme's files: in a child theme, a small plugin or Google Tag Manager, so theme updates cannot overwrite it. Write down where it is.

How do I check the code is working?

Open the site on a phone and watch for your visit in the Real-Time report. Searching the page source for your UA- tracking ID confirms the code is there.

West Coast Media Solutions Inc. provides web design, web development, hosting, digital marketing, and business consulting to organisations across Canada, drawing on more than twenty-five years in the field.

Not sure Analytics recorded last month?

Give us view access. We will check the tracking code and set alerts so the next gap is caught the morning after.

Start a Conversation