Being able to ensure your troops go where you want them to is one of the key abilities essential for successful attacking. Learn how different troops choose their targets. Generally defence targeting troops like Hog Riders and Balloons will target the nearest defence (although troops like Giants and Golems will avoid having to break a wall if there is another defence fairly nearby that they can target without breaking a wall). Non-defence targeting troops like Dragons or Wizards will target the nearest building (unlike defence-targeting troops they will also target nearby enemy troops or heroes). With care, you can make use of these behaviours to anticipate and control where your troops go.
A common failure in attacks is unintentionally letting your troops go around the perimeter of a base rather than pushing into the area of the base you want to get to fast. Whilst they go around the base they get pummelled by defences, rather than pushing into the interior of the base to quickly eliminate those defences.
To avoid this happening you must ensure that after the first building they attack is destroyed, the next nearest building will be in the direction you want the troops to head. To achieve this, use a few troops early on to eliminate buildings that will pull your troops around the perimeter of the base. This is called funnelling. Nearly every attack will require a funnelling plan.
(i) Leaving buildings near the side of your main force deployment that cause your troops to go around the base rather than into it.
In this example, troops that destroy one of the army camps are just as likely to head to the barracks to the sides as they are to the cannon in the middle. Once they destroy the barracks they will head to the next barracks along. So some of your troops are guaranteed to go for a walk around the base.
To avoid this, destroy the four barracks with a few troops before launching your main attack.
(ii) Destroying too many buildings in the direction you want your troops to go, before launching your main force. This leaves no buildings for the main force to target in right direction, so they will target something further along the perimeter instead.
In this example, the player has waited too long to deploy his pekkas. So many of the internal buildings in the middle have been destroyed that there is nothing left for them to target inside the base. So they will target the builders huts around the outside instead.
To avoid this, deploy your main force as soon as the funnel is ready. In this case, there is no need to wait until the army camps and the cannon in the middle is down. These buildings help draw your troops in. You just need to destroy the barracks to the sides. After those are down everything you deploy will path from the army camps to the cannon to the interior of the base. Try to deploy slower short-range troops (like pekkas and the Barb King) before faster long-range troops (like wizards and the Archer Queen) since the latter may kill buildings before the former reach them.
(iii) Not protecting your troops that create the funnel (e.g. the wizards that kill the barracks). You can use your golems to do this, or if necessary a few extra giants. Plan which buildings you wish to take out, and make sure your tanks will be protecting any units that will be in range of defences. Use a few minions instead of wizards if they can attack a building that isn't protected by any defences that target air troops.
Below we see a good plan for creating the funnel. A couple of Golems are sent in first to draw the fire of all the defences nearby. A wizard is placed on each of the four barracks, protected from enemy fire (in the grey ellipse) by the Golems. For good measure, a couple of minions are used to destroy the builders huts, making the funnel even wider.
As soon as the barracks and the builders huts are down, the main force can be deployed, and will have nowhere to go except towards the centre of the base and through the jump spell.
Whilst most videos detailing an attack plan will feature some advice on funnelling, the following ones deal with it specifically. It is useful to get to the point where you understand funnelling well enough that when discussing strategies for hitting a base, someone can suggest "Attack from the South" and for you to understand this to mean "Attack from the South, but with a good funnel". Some bases are harder to funnel than others, so if you are unsure of how to, ask for further advice rather than assuming none is required.
I can't emphasize how important getting to grips with funnelling is. It will help literally every attack you do.
The first two videos below cover funnelling for ground attacks like GoWiPe. The same principles apply to the kill squad portion of a GoHo or GoLaLoon attack. The third video covers funnelling for dragon attacks.
And a nice concise one by OneHive: