How to shortcut pwm and analog pins

I connected an Arduino output (pwm) pin to the gate of a mosfet. The same gate is connected to another circuit (with its own logic, common ground with the arduino) that can source power in the 0/5V range.
Despite i'm not sure the Arduino board is safe with this connection, I already tried to power it up and everything seems fine and work as expected.

Now Id like to extend my setup with the possibility to read the voltage level on the same mosfet's gate. My first thought was to connect an analog pin directly to the gate but before doing that I realized that I'm trying to read an analog value on a square wave, hence my reading would always be either very near to 0 or very near to 1024. I read somewhere that I need a low pass filter to do so. Do you have any advice on the resistor and capacitor I need, in order to achieve a nice measure?
Also can I connect the analog pin straight to gate ( causing a shortcut between the pwm and the analog pin ) or I risk to damage the board? What about simply adding a resistor?

p.s. I'm quite sure I already read something about this but I couldn't find it anymore!

Something like this should work.

Thank you! I'll give it a try

Probably, you should read Drain voltage or voltage across current sensing resistor in the Source path. Filtered out voltage at the Gate, would be in direct proportion to analogwrite value and has not much meaning