Hitching and hiking in Spain should really be avoided, but can't go unmentioned as many people still do it. It can't be recommended as being a good idea, but if you are going to hitch, try to be as safe as you can be. It may seem an obvious comment, but don't take a lift with someone who you are not completely happy about. Females should not look 'too attractive' and wearing a short skirt is definitely a 'No No'. Hide jewellery or anything that could look to be of value.
Hitching in Spain is not as good as in some other European countries. You usually have to wait for some time, but those who pick you up at last, usually tend to be really nice. In Spain it is very important to talk to drivers. Try talking to drivers at petrol stations and ask them in which direction they are going. Knowing some sentences in Spanish helps a lot. Minor roads in Spain are notoriously bendy and drivers don't consider that there may be someone walking just around the bend.
Be warned that the road down the east coast of Spain (Barcelona-Valencia-Murcia) is notoriously difficult for hitching, and trying to get out of either Madrid or Barcelona can prove to be a nightmare. Regionally there's considerable variation as well, the Basque country, and the north in general, often prove quite easy to get a lift, whereas Andalucia tends to involve long (and very hot) waits.
Hitching is not a good idea unless you really have to. Be warned, it might be a cheap means of travel, but be very careful. Be warned, some local authorities have laws which insist that you wear fluorescent coloured 'waistcoat' over your clothes if you are walking along roads in the countryside.