Connecting an inductive sensor to the Anet A8
I am not entirely familiar with the ANET A8 electronics, but it's very unlikely it's any different from how any other mainboard works, so any instructions that work for RAMPS should work for your board as well.
The sensor you linked to has an operating voltage range of &quot;6V to 36V&quot;. However, the endstop connectors (on any mainboard I've come across) only provide 5V - not enough for the sensor to work. You could verify that this is also the case for your ANET board with a multimeter.
(Assuming the colour coding is standard) you'll need to connect the black wire to GND, the red wire to 12V, and the yellow wire through a diode to the signal pin of the endstop connector. The anode of the diode should connect to the signal pin and the cathode to the wire coming from the sensor.
The diode is required, because otherwise the 12V signal from the sensor will damage your electronics, which can only accept 5V. Any ordinary diode will do (for instance 1N4148). You should enable endstop pullups in your firmware when using this method (though if your board already has physical pullups this is not necessary but won't hurt either).
Note that if the sensor is inductive, it will also need an appropriate (metal) surface to trigger off. Unfortunately, it is not clear from the product description what type of sensor you have bought, and (amusingly) gearbest doesn't know either:

Question:
Hello, is this Sensor capazitiv or induktiv? Thank you verry much.
Reply:
It is an auto leveling sensor for 3D printers