Get a fish tank water-testing kit from the pet store, which should include testing equipment for reading ammonia, nitrite, nitrate, and pH levels. Several natural processes that occur in your tank can be kept in check by setting up your tank properly, but certain parameters still need to be tested for every week. Ammonia is a natural byproduct of the food your goldfish doesn’t eat, as well as the goldfish’s waste.  Bacteria will eat the ammonia in your tank, but if the bacteria die or something else goes wrong, high ammonia levels can become extremely dangerous.  If you’re getting positive ammonia readings, change the tank’s water immediately. Determine whether overfeeding, an insufficient filtering system, or overcrowding and remedy the issue as soon as possible. Nitrites are usually converted by your water filter into nitrates, but can make your goldfish unhealthy if not kept in check.  During cycling, nitrite levels may reach 0.75ppm, but should never exceed this amount. Keep nitrate levels between 5 and 20ppm.  Change the tanks water if nitrites are present.  Their presence indicates ammonia levels are likely also too high, or your filtration system needs to be adjusted. Nitrate, which is safe at low levels, can also be harmful at higher levels and can lead to unwanted algae in the tank. A partial water change should be sufficient to reduce nitrate levels. Water that is too acidic will allow ammonia levels to increase very quickly.  Water that is too alkaline (or basic) actually makes natural levels of ammonia more harmful.  Shoot for the ideal levels of pH for goldfish, which are between 7.2 and 7.6 pH. If you need to adjust pH, do so minimally by adding pH decreaser or alkaline buffers that are designed for this purpose, and are available online or in pet stores. Use water generated by reverse osmosis if you are unable to change the pH of the water you're using.  You may be unable to adjust the pH of certain municipal water supplies because of specific mineral content in the water.

Summary:
Test your goldfish’s water weekly. Keep ammonia levels at 0ppm. Maintain nitrite levels at 0ppm and nitrate levels below 40ppm. Ensure a pH-balanced tank.