When installing a cap, make sure it is firmly secured. High winds, or tree limbs moving around can bring a chimney cap crashing to the ground.
If the cap is not stainless or copper, it will need to painted periodically, just like any metal exposed to the elements. If the rust gets established, you may never get rid of it. Protect your investment.
The cap should be at least 5 inches higher that the top of the flue pipe. You must allow at least that amount of space for the smoke to escape. If the cap is too close to the opening of the flue pipe, the it will create a back pressure and smoke will come into the house.
The cap should ideally overhang slightly to keep out blowing rain. This is not that important though, if you want the cap to be even with the chimney walls for looks. The base of the chimney cap should wrap around the brick, stone, or pan, so that rain and sun are kept away from the top 1 or 2 layers of brick (or whatever your chimney is made of).
The chimney cap should have screen incorporated into it to keep animals out. A cap without screen, could actually make an inviting place for some animals to nest under it. This could block the smoke, or worse, collapse into the chimney bringing wild animals with it.