The first time a device loads your content and a hit is recorded, Analytics creates a random, unique ID that is associated with the device. Each unique ID is considered to be a unique user in Analytics. This unique ID is sent to Analytics in each hit, and every time a new ID is detected, Analytics counts a New User. When Analytics sees an existing ID in a hit, it counts a Returning User.
It’s possible for these IDs to get reset or erased. This happens if a user clears their cookies in a web browser, or uninstalls and then reinstalls a mobile app. In these scenarios, Analytics will set a new unique ID the next time the device loads your content. Because the ID for the device is no longer the same as it was before, a New User gets counted instead of a Returning User.
The unique ID that Analytics automatically sets is specific to every device, but you can customize how Analytics creates and assigns the ID. Rather than using the random numbers that the tracking code creates, you can override the unique ID with your own number. This lets you associate user interactions across multiple devices.
A session in Analytics is a collection of interactions, or hits, from a specific user during a defined period of time. These interactions can include pageviews, events or e-commerce transactions. By default, a session ends after 30 minutes of inactivity. This is called the session “timeout length.” If Analytics stops receiving hits for a period of time longer than the timeout length, the session ends. The next time Analytics detects a hit from the user, a new session is started. The 30 minute default timeout length is appropriate for most sites and apps, but you can change this setting in your configuration based on your business needs. For example, you might want to lengthen the session timeout if your website visitors or app users do not interact with your content frequently during a session, like if they watch a video that’s longer than 30 minutes.