How to fetch the SID on the Subscription allow event?

I want to trigger the fetching of SID whenever a subscriber opts-in.
How can I achieve this?

My end goal is to schedule notifications to them with a 24h delay since they subscribed.

Please use the following code, the SID hook triggers automatically when a user is subscribed

   webpushr('fetch_id',function (sid) { 
        //save id to database
        console.log('webpushr subscriber id: ' + sid)

Please I’m so not proficient in js console.log().
I need to get sid into PHP variable.
Also where exactly should I place the above script?

Please advise.