You will need to download the LSM303 library from GitHub and place it inside your libraries folder.
To begin you should run the calibrate example to get the maximum and minimum values for your particular robot. During this phase you should move the robot through every possible orientation. Using the serial monitor you will be able to get six values that you can use in the next phase.
The following script shows how once calibrated the robot can read its heading.