Referral link and number of redirects on confluence page

I’m trying to create a function that will render referral links and number of redirects.
To elaborate more I have a plugin that redirects to specified url with number of delay.
So, i’m trying to get the referral link and also get the number of redirect.
I have looked at the confluence doc but not much help.
Can anyone help, please.