How Visits are calculated in Analytics
The concept of a visit in Google Analytics is important to understand because many features, reports, and metrics depend on how Analytics calculates visits.
A visit is a group of interactions that take place on your website within a given time frame. For example a single visit can contain multiple pageviews, events, social interactions, custom variables, and ecommerce transactions. Learn more about the different request types in Google Analytics.
You can think of a visit as the container for the actions a visitor takes on your site.
A single visitor can open multiple visits. Those visits can occur on the same day, or over several days, weeks, or months. As soon as one visit ends, there is then an opportunity to start a new visit. There are two methods by which a visit ends:
- Time-based expiry (including end of day):
- After 30 minutes of inactivity
- At midnight
- Campaign change:
- If a visitor arrives via one campaign, leaves, and then comes back via a different campaign.
How long does a visit last?
By default, a visit lasts 30 minutes, but you can adjust this length so a visit lasts a few seconds or several hours. A visit can be as short as a few seconds or as long as several hours. But by default, visits last 30 minutes. See how Google Analytics defines bounce rate and visit length.
When a visitor, say Bob, arrives on your site, Analytics starts counting from that moment. If 30 minutes pass without any kind of interaction from Bob, the visit ends. However, every time Bob interacts with an element (like an event, social interaction, or opens a new page), Google Analytics resets the expiration time by adding on an additional 30 minutes from the time of that interaction.
Assume Bob interacts with your website at the following intervals:
After event 2, the visit expiry is set to 14:34
When Bob first arrives on your site, the visit is set to expire at 14:31. As Bob continues through your site, viewing pages and triggering events, each of these additional requests moves the expiry ahead 30 minutes.
What happens if during a visit to my site, Bob leaves open a page while he takes a 31-minute lunch break, then returns to continue browsing the site?
In this scenario, the first visit that was opened when Bob arrived on the site ends 30 minutes into his lunch break. When he returns from lunch and continues browsing the website, then Analytics sets a new 30-minute expiry, and a new visit begins.
Bob was half way through a product purchase when he left your site and went for lunch. He later returned to complete the transaction. The landing page of the new visit is the add-to-cart page.
What happens if Bob leaves open a page on my site, but only takes a 29-minute lunch break before he continues browsing?
When Bob returns, the visit that was open continues from the last page he was viewing on your site (provided he doesn’t return via another campaign source -- a bit more about this below). As far as Analytics is concerned, he never left your website.
Bob was half way through a product purchase when he left your site and went for lunch. The difference this time is that because he returned in under 30 minutes, the old visit remains open. It’s worth noting that his time on page for pageview 2 (product) is 29 minutes, since time on page is calculated as the difference between the initiation of successive pageviews: pageview 3 - pageview 2 (14:31-14:02 = 00:29).
End of day expiry
Bob visits your website at 11:50 PM on the 14th of August and leaves your website at 12:10 AM on the 15th of August.
The first visit ends at 11:59:59 PM on the 14th of August, and the second visit begins at 12:00 AM on the 15th of August.
End of day is determined by your view timezone settings.
Campaign change expiry
Every time a visitor's campaign source changes, Google Analytics opens a new visit. It’s important to point out that even if an existing visit is still open (that is, less than 30 mins have elapsed), if the campaign source changes mid-visit the first visit is closed and a new visit is opened.
Let’s say Bob visits your website in the following order:
Analytics stores campaign source information. Each time the value of the campaign is updated, Analytics opens a new visit. In the example above, Bob first arrives at your website via the Google organic keyword Red Widgets, then later returns via the Google paid keyword Blue Widgets.
Each search term updates the campaign, so each keyword corresponds to a new visit.
What causes updates to the campaign?
Generally speaking, the campaign updates anytime the visitor arrives at your site via a search engine, referring website, or campaign tagged URL. Direct traffic, however, never updates or replaces an existing campaign source such as a search engine, referring site, or campaign-tagged information.
In the case of AdWords autotagging, each click generates a unique campaign value (a gclid value). Because each click has its own gclid value, each click is treated as a separate campaign and creates a new visit.
We generally don’t recommend manually tagging your AdWords campaigns (see benefits of autotagging), but let’s assume that you manually tagged your AdWords campaigns with a destination URL like this:
Bob clicks your ad, which registers a new visit for the first click. However, unlike autotagging, where multiple clicks on the ad can generate multiple corresponding visits, manually tagged campaign parameter values remain the same for every click so the campaign isn’t updated for each click. This makes it possible to have multiple ad clicks and only one visit.
If you advertise on third-party ad networks and use manual campaign tags, you should be aware that each click from a single visitor on those networks might not generate a corresponding visit (if additional clicks happen within the 30-minute time frame). This is a common cause of data discrepancies between Google Analytics and other product reporting.
Referring sources -- a slight exception
Each new campaign source should generate a corresponding new visit, but referrals are treated differently from search engine traffic (organic, cpc), and campaign-tagged traffic. A visit from a referring source within the 30-minute visit window doesn't update the campaign.
Let’s assume Bob visits your site via the following sequence:
If Bob returns to your site via a referring source, Analytics does NOT update the campaign or open a new visit.
Why is this campaign source treated uniquely?
There are a few reasons why referrals are treated differently:
Let’s say your website has a 3rd party payment gateway:
Assume the third-party payment gateway (paymentdomain.com) doesn’t allow cross-domain tracking. To prevent Analytics from losing your original campaign information (organic keyword Red Widgets) and overriding it with referral information from the third-party payment gateway (paymentdomain.com), Analytics ignores referral sources when a visit is still open.
The caveat is that if visitors spend longer than 30 mins on the payment gateway pages, Analytics updates the campaign with referral information from paymentdomain.com when the visitor returns to the thank-you page on yourwebsite.com
On some occasions despite your best efforts it’s possible that you miss tagging a page, or the Google Analytics tracking code doesn’t function on a subset of pages. In these instances where some pages are tagged and some are not and without the special treatment of referral traffic Google Analytics would override existing campaign information “Red Widgets” with self referral information from yourwebsite.com.
Because Google Analytics does not update the campaign when the existing visit is still open, your original campaign data Red Widgets is preserved up until the thank-you page, and your conversions can be traced back to this keyword.
Finally, a quick word about direct traffic in Analytics. Direct as a campaign source never overrides an existing known campaign source like a search engine, referral, or campaign source would.
Direct visits that occur within the 30-minute visit window have the same effect as leaving your website for less than 30 minutes. The existing visit opens and continues from where it left off.
Note that the Multi-Channel Funnel reports handle direct visits differently than other Google Analytics reports.
Bounce rate: Can be defined as a single interaction with your website followed by an exit. Some types of interactions, like Events, allow you to specify if the request should be excluded from the bounce rate calculation. Refer to the Developer Guides for Events in Universal Analytics (analytics.js) and Classic Analytics (ga.js) to see how to implement this.
Visit length: The default visit length is 30 minutes, but you can change this by adjusting the session or campaign timeout handling if you're using Universal Analytics (analytics.js). If you're using Classic Analytics (ga.js) refer to our Developer Guide on how reduced or extended the timeout length method in ga.js.