A device and method is provided for treating treat gastrointestinal disorders using electrical stimulation. In one advantageous form, the method uses mucosal EGG (mEGG) to analyze a patients natural gastric electrical activity. The mEGG can be measured anywhere in the gastrointestinal tract. From the mEGG, one can determine whether a patient is a good candidate for gastrointestinal electrical stimulation. For example, analysis of the frequency, amplitude and a ratio of frequency to amplitude can be used to determine who should receive gastrointestinal electrical stimulation, and at what the various stimulation parameters should be. The present method can be used to treat various disorders relating to gastrointestinal electrical activity. Ideally, the gastric electrical stimulation is delivered at a desired frequency and amplitude to effectuate normalization of gastric electrical current/activity, thereby treating disorders associated with gastric electrical activity. Advantageously, gastrointestinal electrical stimulation is effectuated by endoscopically delivering the electrostimulating device.