Geochemists use several elements to track the history of a batch of magma. For our example we'll start with magnesium (and think of it as magnesium oxide, MgO, like the geochemists do). Beneath Hawaii, when the mantle melts it produces a magma with about 17 weight percent MgO. Volcanologists call magma with this composition a picrite. As the magma rises crystals begin to form. The first crystal to form is olivine, which contains the elements magnesium, silicon, and oxygen in the proportions 2 to 1 to 4. The crystal is more dense than the surrounding magma and it begins to settle. It is estimated that an than the surrounding magma and it begins to settle. It is estimated that an olivine crystal 1 mm in diameter falls through the magma at a rate of 20 meters per hour. By settling the crystals are being removed from the magma, causing the chemical composition of system to change. As more and more olivine crystals settle, the magma has less and less magnesium oxide and more and more silica. For most volcanoes, by the time the original magma from the mantle is erupted its composition has changed from a picrite to a basalt.
If the magma is not erupted, the same process continues but more and different minerals become involved. In general, the removal of these crystals drives the composition away from that of a basalt and towards that of a rhyolite. The amount of magnesium oxide and iron oxide continues to decrease and the amount of silica, sodium oxide, and potassium oxide increases.
Other processes can become involved. The magma may melt and incorporate crustal rocks that tend to contain more silica. This drives the composition towards rhyolite. The rising magma may also intersect and mix with a magma that has evolved differently. This will also change its composition.
These processes (crystal settling, assimilation, and magma mixing) influence the composition of the magma. Geochemists study the minerals and the chemistry of the lava to determine which processes were involved and how big of a role each one played.
Source of Information:
Clague, D.A., and Denlinger, R.P., 1994, Role of olivine cumulates in destabilizing the flanks of Hawaiian volcanoes: Bulletin of Volcanology, v. 56, p. 425-434.
P.S. Clague and Denlinger report the following composition for average Kilauea primary magma: SiO2 (49%), TiO2 (1.9%), Al2O3 (10.7), FeO (11.2%), MgO (16.5%), CaO (8.55%), Na2O (1.66%), K2O (0.30%), P2O5 (0.18%).