Unity Analytics (New) - Events.Transaction()

Hello!

I’m just implementing Events.Transaction() in the new Unity Analytics…

https://docs.unity.com/analytics/RecordingTransactionEvents.html

Is there a minimum set of parameters that Unity Analytics requires to report useful data? I’m wondering if parameters like transaction, receipt & store ids are mandatory or optional?

At present, I’m just looking to send product id, price & store type.

Is there also any reason why TransactionServer is limited to Amazon, Google & Apple at present? It would be good if Microsoft (and others) could be added as well please.

Any help would be much appreciated.

Hi David,

Thanks for pointing this out. We will speak to the team and make some updates to the documentation.
If you navigate to your dashboard Analytics > Event Manager > transaction. You can see what fields are required and what fields are not required. You can remove parts that are not required in example.

Must be provided by the client (required)

  • eventParams
  • productsSpent
  • producteRecieved
  • transactionName
  • transactionType

Handled by the SDK

  • eventVersion
  • userID
  • clientVersion
  • sdkMethod
  • eventName

Let me look into why TransactionServer does not at least include (OTHER). TransactionServer would be for validating purchases with the respected providers Microsoft may not offer transaction validation. I will confirm with our team.

I’ve also included the StandardEvents Sample to this thread which could be found in the samples section of the package manager.

NB: TransactionType must be PURCHASE for reporting on the dashboard

Let me know if you need further help while I take this back to our team.
Best,
Seb

7932130–1013419–StandardEventSample.cs (7.73 KB)

Thanks @SebT_Unity

Apologies, I missed that field in the event manager.

Ah I thought that was the platform the transaction occurred on, not verified on. So yes, Microsoft does not currently offer receipt validation. So “None” and\or “Other” options would be welcome here.

Thanks for pointing that out. It definitely helps, but they’re all defined as SALE transactions which means they will not be reported on. I’m assuming SALE and PURCHASE are identical in terms of properties defined?

Real Currency Data Type

The one big issue I’ve come across is the use of integers for real currency. This very non-standard and is going to cause more work for developers and result in potentially inaccurate data imho.

Whilst integers can be converted to decimals accurately, the same is not true the other way around. Unity’s own IAP system even offers the price in decimal. Which means to pass it through to analytics it has to be converted to an integer.

Whilst most currencies use two decimals places, some use three and some none. Which means developers are now going to have to take on this extra responsibility. Short of handling each currency type individually, I guess a workaround would be to convert the decimal to a string, strip out any non-numeric characters and convert to an integer, but this just feels hacky.

I’m guessing it’s too late to change, but is there a reason why integers were chosen to represent real currency?

Hi David,

For the standard measure reports PURCHASE is required. The sample will be updated accordingly.

The real currency data type being an integer is by design.
We wanted to support a multitude of currency so that dashboards would follow accordingly.

Let me further investigate the extra responsibility developers have to convert. If a helper method was included with the SDK would that help? In the meantime you can look at the following website to help with the conversion process

As soon as I have more information I will post here.

Thanks for this valuable feedback.
Seb

1 Like

Thanks for the update @SebT_Unity

Decimal would give you that support for real world currency as well as virtual, without the pain of conversion. But it looks like things are too far developed to consider a change.

As for the help method that would be a very useful addition.

I’ve written my own and it produces this…

USD 0.99 = 99
USD 1.99 = 199
TND 5.875 = 5875
JPY 228 = 288

Tbh it might be best to have an overloaded Transaction method on Events that takes the individual mandatory parameters (in their raw form) that also handles any required conversions. That will really help with data consistency and reporting.

Just an idea anyway :slight_smile:

1 Like

Thanks again David, Your feedback is indeed very valuable.
Your own helper output seems right.

A helper is currently being looked into. Ill post back here once released.

Best,
Seb