The picture may help clarify things:
https://upload.wikimedia.org/math/a/b/4/ab47f643c7918fda58089c7f5129a183.png
Then again, it may not...
Essentially the ontological argument is about slightly more than just "if I can imagine something it must be real", but rather "if I can imagine something
perfect then it must be real" -- since, the argument goes, existence is a necessary condition for perfection.
This is not necessarily as stupid as it sounds, or as contributors above would suggest, although the argument has a number of possible flaws: most notably, it fails to establish which God you are talking about when referring to a "perfect being". The image above, for example, merely "proves" (accepting as correct and consistent the definitions Df and the axioms Ax) that some object x exists containing all possible "positive" qualities, whatever those are.
The second problem is whether or not you can define such positive properties in a consistent way, or if it even makes sense to have such a thing as "perfect". Thus, the question the argument poses to start with is something like: "is it possible that a prefect being (God) exists?" If the answer to that is "no" to start with, then that's the end of the matter. But if not, and it is possible for there to be such a perfect being, then it does sort of follow that perfection implies existence.
It can be surprisingly compelling, if you think about it long enough. Perhaps that's overthinking, although that said the basis of the argument is worth looking into. See here, as an example (which also helps to explain the scribbles in the image above):
http://www.stats.uwaterloo.ca/~cgsmall/ontology.html