umbraco-community / umbraco-analytics

Google Analytics for the Umbraco CMS
40 stars 31 forks source link

Change hardcoded currency #11

Closed bjarnef closed 9 years ago

bjarnef commented 9 years ago

Consider how to seet which currency that should be used. In Google Analytics there is a setting "currency shown as", which I think you can get through the API.

2014-10-01_23-18-31

Or perhaps a dropdown in the package settings view with a dropdown with the same currencies. I am not sure how the it will affect the price - in my example I use ecommerce data from a webshop, where the currency is send to Google Analytics in DKK.

warrenbuckley commented 9 years ago

Some useful links for reference:

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/profiles/list

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/profiles#resource

https://developers.google.com/apis-explorer/#p/analytics/v3/

This also looks interesting to look at: https://developers.google.com/analytics/devguides/reporting/embed/v1/ https://ga-dev-tools.appspot.com/demos/embed-api

abjerner commented 9 years ago

I have only looked a little into the work you have made on the transaction view, but I think the scope already has the information you need.

The currency of a given profile is already part of the information saved in ~/App_Plugins/Analytics/profile.config.

So in a controller, you should be able to get the currency through $scope.profile.Currency.

Let me know if this works for you ;)

warrenbuckley commented 9 years ago

@bjarnef & @abjerner any news/updates on this guys?

bjarnef commented 9 years ago

@warrenbuckley I had submitted a PR so it just use the currency set as default in your GA profile, but later it maybe should be possible to change it from settings.

warrenbuckley commented 9 years ago

OK looks like I can close this then @bjarnef, as I merged in your PR this morning here https://github.com/warrenbuckley/Analytics/pull/14

abjerner commented 9 years ago

Regarding later being able to change the currency, I don't think that is possible. As far as I know, The API will just return the currency as specified in Google Analytics. But then again, I haven't worked much with currencies in Analytics.

It is of course possible to do some conversion after the data has been fetched from the API, but requires another service for looking up the exchange rates.

bjarnef commented 9 years ago

Yes, for now you can just switch the currency for your Google Analytics profile, but I was also thinking that some editors might use different language and prefer different currencies. I am not sure how Google Analytics handle the conversion e.g. when I have a webshop with prices in DKK and Google Analytics track the orders and I then i Google Analytics can change the currency and e.g. see prices in USD. They probably use a service for the exchange rates - maybe Google has its own service for that - but it have to be up-to-date with latest exchange rates.

bjarnef commented 9 years ago

This one seems to be popular https://openexchangerates.org/showcase

But I think some free services / open source code could be used. https://github.com/petebacondarwin/angular-exchange-rates

http://www.programming-free.com/2013/11/currency-converter-angularjs-aspnet.html

The last example use exhange rates from this xml http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml from European Central Bank.