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

Session unification with transaction

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there, not sure if this forum is able to tackle technical implementation questions but I'm not getting much love on stack exchange or the analytics group so I thought I'd try here.

 

We have an app that is successfully using Google Analytics to report data, the client is written in Unity and has an initial connection event that sets up the session and then a fair number of non-interactive events on the server unify with this session - so far so good. The problem is that once we verify a transaction with Google or Apple, the server sends a transaction event and this event fails to unify with the session so that all of our transactions are from an unknown country.

 

The transaction data looks something like this:

{
    "v":1,
    "tid":"UA-XXXXXXXX-1",
    "ds":"cloud",
    "an":"App Name",
    "aid":"com.example.appname",
    "ni":1,
    "uid":"AXUflYS8x3",
    "geoid":"",
    "uip":"",
    "t":"transaction",
    "ti":"1000000181XXXXXX",
    "ta":"apple",
    "tr":1.49
}

I am inclined to think that this is some kind of a bug and that I should report it as such - can anyone tell me otherwise?

 

Cheers,

 

 

  ..alex

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Alex W
November 2015

Re: Session unification with transaction

Top Contributor
# 4
Top Contributor
Hi Alex,

userId is only used with the userId enabled view (this is where user level reporting happens in a way) yet without the client Id GA has no way of knowing which users session it needs to stitch as client Id is the ID that does that so it is necessary to provide that info to GA on each hit.

If you check basic web pageview tracking - each hit has the client Id attached which basically identifies the device (cookie, not the user) therefore Google introduced a separate dimension User Id which ties multiple devices to a single user - user Id does not stitch sessions afaik it only unifies the session - backfills the hits inside a session to a specific user - but it still needs the client Id.

A similar approach is used when you deal with any kind of delayed sales or offline sales - collecting client Id in your CRM is basically essential as all hits generated from the CRM need to have that parameter included.

For more help also try to validate your MP hits with this - https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits and https://ga-dev-tools.appspot.com/hit-builder/

Hope it helps.

Kind regards,
Zorin





Web analyst @ escapestudio.net

View solution in original post

Re: Session unification with transaction

Top Contributor
# 2
Top Contributor
Hi Alex,

so you use Measurement protocol to send a delayed transaction? Are these all of the parameters you set in the payload? If so you would need to add the cid parameter (clientId) so the session may be preserved. Please note that there is a limit to how much you can delay the transaction.

Also is there any reason you would send a transaction as a non interaction hit?

Kind regards,
Zorin
Web analyst @ escapestudio.net

Re: Session unification with transaction

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Zorin, the event is being sent by the server rather than the client - so we don't have the cid (which is on the client) and that is why it is going as non-interaction. I thought that it was able to use the uid to unify sessions, is that not the case?

I suppose it would be possible to modify the client to pass the cid back from the client but that seems counter-intuitive, especially if the user had two client machines (say tablet and phone) that they were using interchangeably with the same account.
Marked as Best Answer.
Solution
Accepted by topic author Alex W
November 2015

Re: Session unification with transaction

Top Contributor
# 4
Top Contributor
Hi Alex,

userId is only used with the userId enabled view (this is where user level reporting happens in a way) yet without the client Id GA has no way of knowing which users session it needs to stitch as client Id is the ID that does that so it is necessary to provide that info to GA on each hit.

If you check basic web pageview tracking - each hit has the client Id attached which basically identifies the device (cookie, not the user) therefore Google introduced a separate dimension User Id which ties multiple devices to a single user - user Id does not stitch sessions afaik it only unifies the session - backfills the hits inside a session to a specific user - but it still needs the client Id.

A similar approach is used when you deal with any kind of delayed sales or offline sales - collecting client Id in your CRM is basically essential as all hits generated from the CRM need to have that parameter included.

For more help also try to validate your MP hits with this - https://developers.google.com/analytics/devguides/collection/protocol/v1/validating-hits and https://ga-dev-tools.appspot.com/hit-builder/

Hope it helps.

Kind regards,
Zorin





Web analyst @ escapestudio.net

Re: Session unification with transaction

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Many thanks will investigate an alternative implementation.

Re: Session unification with transaction

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
OK well we have changed our implementation so that both the server and client are now submitting a client id along with a user id - however still the non-interactive events sent from the server, including the transactions, are failing to unify with the client data. Consequently we are seeing our transactions come through with a (not set) country identity which presumably comes from the server setting an empty string override for ip and geoid. If I do not override these values however then I get a US location from the server IP address.

Re: Session unification with transaction

Top Contributor
# 7
Top Contributor
Hi,

what is an average delay time between the time a transaction has been made and a hit to analytics has been sent via MP?
Web analyst @ escapestudio.net

Re: Session unification with transaction

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭
It's essentially real-time so there's no delay or not more than a second or two.

Re: Session unification with transaction

[ Edited ]
Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

As Neil says - the client makes a purchase and receives back a receipt, this is sent to the server, the server verifies the receipt and then sends the transaction analytics event.

The client sends an event when it initialises via the unity Google analytics plugin - this is the Auto Instrumentation event. From that point onwards analytic events tend to be sent from the server rather than the client (it is a faster turn-around to modify the server code). So from that first client side event to subsequent server side events could go over the 30 minute session cut-off. However at the moment all events sent from the server are failing to unify with that initial session start event regardless of the time difference.

Re: Session unification with transaction

Top Contributor
# 10
Top Contributor
Hi Alex,

ok, I understand a bit more what you are doing.

Let's try the following:
1. When the client initializes send a screenview / pageview and not an event (especially not a non interactive event) as you will have session start issues
2. When you send a transaction via MP there is no need for the ni parameter to be there (leave it out)

When you deal with delay which may cause a new session you have a new parameter available queue Time - https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters?hl=en#qt

Hope this helps.
Kind regards,
Zorin
Web analyst @ escapestudio.net