Custom dimensions not being tracked

Hi, we are trying to implement the custom dimensions via Google Tag Manager but they are not being tracked, the custom dimension page for the JSESSIONID in Matomo says: There is no data for this report.
We followed the guide: Custom Dimensions User Guide - Analytics Platform - Matomo.

We have used this code:

But it is not tracking. We are able to track just by sending a separate event, but then we have the data in the Events tab.
What are we missing here?
Thank you!

Actually custom variables are working properly instead. Why this is happening?