1.use a tamp that fits your basket as close as possible without being too tight - your tamp should not bind on the endges of your coffee basket.
2. when tamping, be aware of the pressure you are applying sideways - try to maintain a level surface
3. apply around 15kg of downward force (you can tamp on to a set of scales to get a feel for the pressure required.
4. be careful not to bump the coffee basket after grinding - that includes knocking it with the tamp of the grouphead.
So, although the perfect coffee is a science of sorts, knowing the tricks will really help you make a great coffee. The best advice I can give you is to be consistent.