As in most other countries these days, we do not recommend hitching in Spain as a safe method of getting around.
If you are determined to hitch, be warned that the road down the east coast (Barcelona-Valencia-Murcia) is notoriously difficult, and trying to get out of either Madrid or Barcelona can prove to be a nightmare (you're best off taking a bus out to a smaller place on the relevant road). Thumbing on back roads is, however, often surprisingly productive; the fewer cars there are, the more likely they are to stop.
Regionally there's considerable variation as well: the Basque country, and the north in general, often prove quite easy, whereas Andalucía tends to involve long (and very hot) waits.