Right behind the cab on the bed rail is actually the worst place to put such an antenna, and the more separation between the antenna and the cab, at least to a point, the better. The presence of the cab affects both the antenna's tuning and performance. I'm not saying that you can't make an antenna work ok in such a location, but it will never work as well as it could.
If you have trouble tuning an antenna mounted at either the front or rear corner of the bed, moving the antenna towards the middle of the bed rail will almost always help, and it doesn't generally take a large amount of moving said antenna to get this effect. With some antennas you can literally tune them simply by moving where they are connected to the bed rail, forward and backwards on the truck.
If you are looking to steer gain in one direction, from experimenting with my field strength meter I can tell you that peak gain in general will be to the far corner of the bed from where the antenna is mounted, so if you want peak gain to the front of the truck then you want to mount the antenna to the back of the bed, and vice versa. Modeling agrees with this, and according to modeling, with most pick up trucks, as far as gain is concerned, the cab is actually mostly invisible, having only a small effect on overall gain. This is from a model that separates the cab and bed, and only connects the two through the frame (you know, how most pickup trucks have been built for decades). If you want the best omnidirectional performance, the best location is, no surprise here, the center of the roof of the cab...
The DB