Several types of tracking technology exist, and the type used depends upon the the circumstances of the competition.
In training, some teams are now tracking with systems like RedFIR, a German technology comprised of tiny (15 gram) radio transmitters that can be placed in uniforms, footwear or balls, and a network of receivers set up around the field. The system detects events like passes, crosses and goals, plus provides real-time info on player step count, speed, and distance covered. Fraunhofer IIS, the company that makes RedFIR, says that its radio-based system provides a major benefit over other tracking solutions: "its tracking capability is not diminished by obstacles obscuring the line of sight."
But so far FIFA hasn't adopted the technology. This may be because rules changes would be required to implant the transmitters into balls. Also, players haven't been to receptive towards adding microchips to their shoes or shin guards during competition.
FIFA relies on a visual tracking technology called "Matrics" made by the Italian company deltatre to provide data that make up the heat maps, passes completed and distance covered stats made available at the World Cup official site.
From deltatre's webpage:
deltatre can very proudly say to have successfully delivered 3 FIFA World Cups™ since 2002 (South Korea and Japan 2002, Germany 2006 and South Africa 2010) and a total of 1.191 matches including other FIFA Competitions: result of continuous investments in software, hardware, training and people.
Motherboard provides a fascinating look at how "Matrics" is being used at the 2014 World Cup.