Analytics
2.2K members online now
2.2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Is there any way to expire the GA cookie manually?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

For instance if someone logs out, expire that session on log out so if someone else logs in right after, their visits are counted as two separate sessions? 

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Mike D
February 2016

Re: Is there any way to expire the GA cookie manually?

Top Contributor
# 2
Top Contributor

Hi Mike :-)
Session Control may be what you are after, Ive not used it before, however I'm thinking from what is said about it, it could possibly be sent with an event (or virtual pageview if required). 
From the Dev Docs:

Used to control the session duration. A value of 'start' forces a new session to start with this hit and 'end' forces the current session to end with this hit. All other values are ignored.

Example value: start
Example usage:

// Starts a new session.
ga('send', 'pageview', {'sessionControl': 'start'});

Reference: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#sessionCont...

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Is there any way to expire the GA cookie manually?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

This is perfect! Is there any real way to test this?