AzUrlShortener icon indicating copy to clipboard operation
AzUrlShortener copied to clipboard

Add country of origin to click count

Open mpowney opened this issue 4 years ago • 1 comments

Other open source URL shorteners like Polr (PHP based) have a country of origin option when viewing number of clicks.

This might add too much complexity to such a lightweight implementation, but worth considering? Looking at polr’s implementation, you’d need a db of IP ranges to match to the countries, or a free service to look this up, plus storing the data needs to comply with GDPR (ie. not persist the storage or source IP addresses, just the country and click count).

Here's a screenshot of the UI in Polr: Screenshot of polr UI

I’d love to help implement this if it’s suitable / you have any thoughts?

┆Issue is synchronized with this Trello card by Unito

mpowney avatar Apr 14 '20 21:04 mpowney

I found the following free "API" that can possibly be called from within the UrlRedirect function to capture the country code/country name based on the IP of the link consumer. It does have a limit of 15000 calls per hour, not too bad for being free. There are other alternative services/apis available that provide this functionality, but that would probably require prior setup of an API Key for one of those services to be added as part of the deployment. This in turn would probably require secure storage of said API Key in a secure store like Azure KeyVault. Additionally, I think that the ShortUrlEntity would need to be enhanced to store the additional details around country and click counts. I am thinking perhaps a Dictionary<string, int> would probably serve as a decent mechanism for capturing the click counts by country.

mreyeros avatar Oct 15 '20 20:10 mreyeros