Downloading Custom Variables

Hey there!!

My Customer Member IDs are in the form of Custom Variables in the Matomo analytics.
In order to extract these member IDs, I had to do it manually which is really time taking.

Can anyone please give me an idea of how these custom variables can be automatically extracted into an excel sheet and download them??