Your code is correct. What you need to check are the server side reports that you create.
Make sure you create custom metrics in Admin - Custom Definitions - Custom metrics. After creation, custom metrics will initially be displayed with a delay of 3 to 4 hours on the server. Give them some time to appear there. Finally, you need to create a report to see the result. Make sure that you select the correct time intervals and do not add too many indicators and filters, otherwise you will not see the data. Make the first repetitions as simple as possible. Hope this helps.
source share