Turn your hat inside out to examine it. Figure out where will be easiest to sew your zippered fabric onto. Sometimes the inside of hats have extra fabric where the top meets the side that you can use. My hat didn't have this and instead had double walls for the sides.
If your hat is like mine then you'll have to sew the zippered lining onto the hat very carefully to make sure that you only go in and out of the inner layer and not the outside one so that you don't see the stitching on the outside.
If your hat has excess fabric that you can sew onto, use that to secure the zippered lining to the hat.
I don't have any pictures of how to sew the lining on because off the stitching took place inside the hat and zippered compartment so there was no way to show it. If you have trouble attaching the lining though you can sew half of it to one side of the hat (fabric upside down) and then lay that the right way over the hat. Unzip the lining so that you can reach in and work from the inside for the other half.
It can get a little tricky but it's worth it for a nicely finished product that hides any sewing mishaps you have.