Analytics
2.6K members online now
2.6K 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

Custom Dimension - Session Id, how to identify session start/end

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I have a single page web application with some Custom Dimensions that are session-level.

 

To my understanding, a session-level custom dimension will take the last value they were set to during that session, then apply them to all events during that session.

 

This is useful, but only if you can identify which session you are in by an ID.

 

Two use cases:

  • sessionStartTimestamp
    • if(!sessionStartTimestamp){sessionStartTimestamp=now()}
  • maxValueOfX
    • if(maxValueOfX<newVal){maxValueOfX=newVal}

The issue with implementing these is when my single page application is refreshed, I have no method of determining if I am in a new session or not (or what the last values of those dimensions were - I can use localStorage but I still need to know the GA session ID).

 

How can I determine which session I am in with JS? Is there an API?

 

https://support.google.com/analytics/answer/2731565?hl=en

 

Custom Dimension - Session Id, how to identify session start/end

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Does any body know if I can get the sessionId from the core reporting API?

 

Custom Dimension - Session Id, how to identify session start/end

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Any one? Please help!

 

Custom Dimension - Session Id, how to identify session start/end

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi!
Here is a topic covering your problem:
https://www.simoahava.com/analytics/improve-data-collection-with-four-custom-dimensions/
session id, client id, hit timestamp