Gel electrophoresis is a way to separate DNA fragments according to their size. You add tracking dye to each DNA sample to help you see the sample and to track the progress of the DNA fragments through the gel.
To separate fragments of DNA, for the purpose of measuring their size or to isolate a particular fragment, scientists put DNA into an agarose gel submerged in a solution that is charged with an electric current. The current pushes the DNA fragments through the gel, and because the gel is porous, smaller DNA fragments worm their way through more quickly. They travel farther than larger fragments in the same amount of time.
DNA is colorless when it is in solution in a test tube. To make the sample easier to see, both in the test tube and in the gel, you add a colored tracking dye to the sample. The dye does not affect the DNA at all.
The usual tracking dye is bromophenol blue in a 50-percent glycerol solution. Bromophenol blue colors the sample bright blue so that it is easy to track its progress through the gel. When the tracking dye has traveled about 3/4 of the length of the gel, it is time to turn off the electrical current.
The tracking dye is dense because of its high concentration of glycerol. That makes the DNA samples sink into the loading slots of the gel, rather than floating away in the solution above the gel that carries the electrical current.
Bromophenol blue migrates through an agarose solution at about the same rate as a DNA strand containing 300 base pairs. If you want to track the progress of larger DNA strands, you can use a tracking dye with xylene cyanol, which migrates at about the same rate as a DNA strand with 4,000 base pairs.