Reputation: 31
I have Google Analytics implemented to my project. All seems to work fine until they asked me to enable ecommerce.
Following all the setup steps, I have enabled ecommerce for my project on GA dashboard and the setup in Unity must be correct since all the other data comes through on the dashboard.
google-play-services SDK is in the project and google analytics module is definitely there.
I am not sure if Unity is using enhanced ecommerce, but I have wrote my code in a way that would work for both. I have tried both options on and off in GA dashboard.
GA.LogItem (transID, itemName, sku, affiliation, revenue, 1);
GA.LogTransaction (transID, affiliation, revenue, 0, 0, currencyCode);
GA.LogEvent ("transaction", "triggered", "", 0);
GA is the object that contains the class GoogleAnalyticsV4 and the information about my app (id and others).
I have tried looking on the internet for other people with the same problem but it's quite hard to find anything about GA + Unity + ecommerce.
I have read all GA docs I could find and I can't find anything I'd be doing wrong.
If you have had this problem, or have any idea why only ecommerce is not being logged to the dashboard, please help me. I've been trying to figure this one out for way too long and I am still lost.
Upvotes: 1
Views: 215
Reputation: 31
So, yeah. I have found the answer to my own problem. I have commented the solution but as MX D suggested I will write an answer to my own question.
So the latest Google Analytics plugin by Google (v4) for Unity has no implementation on the Java side, if you open the script GoogleAnalyticsAndroidV4 and navigate to LogTransaction or LogItem methods, they are empty.
When you are on the editor or not mobile it uses the web handler to send the events to GA, this class has LogTransaction and LogItem implemented.
My quick fix was when the user is using Android and does LogTransaction or Item, instead of calling the android handler it calls the web handler, thus working like a charm.
I hope this explanation makes sense to everyone. If you happen to get stuck and do not understand what I meant here, drop me a line.
;)
Upvotes: 1