Online users gadget

The gadget is not finished. I have some questions that I will ask in the code.
How can I get the id of the space where the gadget is added?