The recommended location is on the instrument panel in view of the pilot. If it is an adjustable type detector, its also recommended to lower the trigger point from the FAA limit of 50ppm to 35ppm.
There's a myth that carbon monoxide alarms should be installed lower on the wall because carbon monoxide is heavier than air. In fact, carbon monoxide is slightly lighter than air and diffuses evenly throughout the room.
Mine is mounted next to where the old tach came out of on my Cherokee which is lower panel next to the throttle quadrant.
Yes, the density changes. But so does air. Air is about 29 grams / mole, CO is 28ish. So not really much difference
Mine went off one day and I had no idea what was making that racket great early warning system as I had a short in the panel. The smoke wasn’t visible until later so it really saved my bacon before something lit off
The CO detector should be somewhere that air is moving around at least a bit, and not in a place where a draft of clean outside air gets at it. In the G1000 system there's a CO detector hidden behind the pilot's flight display. Not normally a good spot, but the PFD and MFD have cooling fans that move considerable air around back there, making sure that CO anywhere nearby will get at the detector.