It only keeps track of the total intensity of the light that strikes its surface. In order to get a full color image, most sensors use filtering to look at the light in its three primary colors. Once all three colors have been recorded, they can be added together to create the full spectrum of colors that you've grown accustomed to seeing on computer monitors and color printers. There are several ways of recording the three colors in a digital camera. The highest quality cameras use three separate sensors, each with a different filter over it.
Light is directed to the different sensors by placing a beam splitter in the camera.
Think of the light entering the camera as water flowing through a pipe. A beam splitter would be like dividing an identical amount of water into three different pipes. Each sensor gets an identical look at the image, but because of the filters, they only respond to one of the primary colors. The advantage of this method is that the camera records each of the three colors at each pixel location. Unfortunately, cameras that use this method are both bulky and expensive.