We measure the gravitational potential energy U of a body (1) by assigning U = 0 for a reference configuration (such as the body at a reference level) (2) then equating U to the work W done by an external force to move the body up or down from that level to a point. We then define gravitational potential of the point as gravitational potential energy per unit mass of the body.
We follow the same procedure with the electric force, which is also a conservative force with the only difference that while the gravitational force is always attractive, electric force can be attractive (for unlike charges) or repulsive (for like charges).