Your First Few Days
The main reason behind this is that you have a Shield which protects you while you build up your defences. At its most basic, you should concentrate on upgrading your resource collectors, which at this stage will only be Gold Mines and Elixir Collectors. You want to make sure you have maxed out the number of each of these that you can build, however. Without adequate storage too, this won't come to anything, so you should also upgrade your Elixir Storage and your Gold Storage. You shouldn't build more Storage stations yet, rather concentrate on upgrading your existing ones.
Because you have a Shield, there is no point in spending your money on defenses such as Walls and Cannons. Your Shield will last for a total of 3 days, so during this time, until you get to the end at least, there's no need to worry about being attacked.
NOTE: If you attack someone in multiplayer, you will sacrifice your Shield. This is not recommended as it will put you open to attack by anyone - although the game itself doesn't make this clear.
When you are just starting out, don't feel you have to spend your Gems just because the game tells you to!
Once you get through the first few days and begin to run out of time with your Shield, you should start on working out your defences. Check our guide to defensive units for picking the best to build, but at this early stage, you should try to build Mortars and Archer Towers, with Cannons being third choice at this stage. Upgrade your defences where resources permit, and build walls to channel enemies into a certain place, or protect crucial structures. TIP: The absolute best thing to do at this stage is to participate in the single-player missions against the enemy Goblins. This gets you a ridiculous amount resources and will really make a difference to the quality of your base (if you attack sensibly, that is).
If you find yourself being attacked by just one soldier, it is probably because the other player is trying to lower their trophy count, and in turn make it more likely for them to get ranked up against easier players in Matchmaking.
Matchmaking is the alternative to fighting against the AI/computer-controlled Clans. This takes place against real-life, human opponents. The opponent you are matched up with them depends entirely on your Trophies. The goal is the same whether you are playing against AI or human players, but with humans you can opt to pay the Gold required to find a match again if you don't like the look of the enemy base. This means that you are not forced into trying to beat an enemy that is stronger than you and, providing you have the Gold, you can search around until you find a base that you like the look of.
Players have started deliberately losing Trophies so that they can then be matched up against weaker opponents next time. You may ask why this is beneficial as they surely will have to have lost a match beforehand to get to that stage? That's right, but they lose these matches by committing just one unit to the fray, for example. This way they haven't shelled any great resources on the defeat, yet will get ranked against someone far weaker than themselves.
Once you get to a really high trophy count you will find many people just attacking you with a single unit. It is unfortunate that people choose to play the game in this way, but there are still plenty of players who are trying to be as successful as possible. You may also find you need to lower your trophy count to get certain achievements, such as the Unbreakable achievement, for example.
There are essentially two types of attack in Clash of Clans, if you discount the deliberate trophy loss strategies. The most familiar has already been described, which is where you set out to try to destroy the opponent's Town Hall. The second is called Raiding, or a similar strategy called Farming. In these scenarios, the ultimate goal of any attack is to get resources. Players will specifically target resource Storages, Elixir Collectors and Gold Mines.
They will send cheap, small armies at unprotected resource sites to pillage the Gold and Elixir. The key to this strategy is that the cost of the army attacking, plus the cost of finding the match, must be lower than the amount of resources the person receives from the attack. Many players choose to attack in this way, so it is certainly a viable tactic for building up a great base.
Raiding armies are also far quicker to train, which means you can attack repeatedly in the time it takes to build up a proper, decent-sized army.
TIP: You can work out if a player is likely to have a lot of Elixir or Gold in their Collectors or Mines by the amount in their bank. If they have lots of Elixir but not much Gold, they have probably been online recently and spent all their Gold, but have a stockpile of Elixir waiting for you to raid!
'Hidden' Building Strategy
A great tip for staying alive and avoiding three-star scenarios while defending is to place a random building at the edge of the map, out of sight. This will mean the enemy has to split their troops, will run out of time while attacking, or will simply not realise that you had a building there at all! Of course, the enemy units, if they have destroyed absolutely everything including Walls, will go to attack it, but otherwise they won't. If you place one in each corner of the map then the attacker is likely to really struggle to 3-star you when they are running out of time.
If you find that you are being regularly attacked by other players, you may be a particularly tempting target for other players. Generally this will mean that you have a lot of resources up for grabs that other players are after. A good counter to this is to spend you resources before you go offline. Queue up units (you can do this even if your Army Camp is full up), perform research, build walls, buy defences and even decorations - just to get rid of your resources.
Your Storage and Mines should either be empty or very well protected. This will discourage other players from attacking you. Don't put all of your Storage or Mines in the same place, either. This will allow your enemies to target one specific section of your base with their entire army.
Upgrade sections of your walls to also help in discouraging enemy attacks.