I'm a huge sucker for statistics and metrics. Sleep tracking, Screentime, step counting, time tracking, looking at the number of commits on github(please don't). All those things give me enjoyment so it's only natural for me to track my music listening habits. People count their steps and listen to music. Why not combine those two? So let's create a widget displaying the amount of songs you enjoyed today.

For this tutorial I assume you're already scrobbling music with Last.fm. If not sign up here https://www.last.fm/join. I personally connected Last.fm to my Spotify, this is in my experience the least difficult way to track music. There are more ways of tracking your listening history. For this refer to the last.fm website to inform yourself about other possibilities.

Last.fm is a social music service. It's goal is to connect you to people with similiar listening habits and gives you weekly/yearly report of the music played in the given timeframe. With all the data the users are feeding it, it's able to give you recommendations on simialar artists and cool new albums to check out.

We are going to use the API of Last.fm to create our widget now. For this login to last.fm and navigate to this page https://www.last.fm/api/account/create fill out the form.

Last Fm API Account Creation Form

Click submit and copy the API Key from the next screen. If you ever need to disable the account or find the key again you can always go to this URL: https://www.last.fm/api/accounts

Now we'll create the actual widget. For this we're going to use the App called Scriptable. Scriptable allows you to write all kinds of automasations for iOS using javascript.

In the Scriptable App click the ➕-Icon in the upper right corner to create a new Script. You're now navigated to a new screen called "Untitled Script". Click on the heading and name the script  let's go with "Last.fm Recent Track Widget".
Now go into the blank space below and paste the following:

Now put in your username and API Key from before into the corresponding places at the top. Press the play button in the bottom right to see if everything works out alright.

Widget Preview

We're basically done now. If you want to you can tweak the colour of the background and text as well to match your personal aesthetic. Refer here to pick your colours: https://g.co/kgs/GHuhEu

Go to the Homescreen on your iOS device. Add a small Scriptable widget and place it to your Homescreen. Long press the widget and choose configure in the following dialog. Choose the "Last.fm Recent Track Widget" and you're done.