Most of the time, the g sound in Spanish is pronounced much like the "g" in "dog" or "figure," except perhaps a little bit softer, especially when it comes between vowels.
However, when g comes before the letters e or i, the sound is the same as that of the Spanish j. The j sound is one that doesn't exist in standard English except in a few words of foreign origin when carefully pronounced.
The j sound is what is known as a voiceless velar fricative, which means that it is formed by forcing air through the slightly constricted back part of the mouth. It's kind of a scraping or raspy sound from the back of the mouth. If you've learned German, you may know it as the ch sound of Kirche. You may hear it sometimes in English in the word "loch" when given a Scottish accent or as the initial sound of "Hanukkah" with a Hebrew accent.
One way you might think of the sound is as an extended "k." Instead of sounding out the "k" in an explosive fashion, try lengthening the sound.
The sound of the j varies with region. In some areas, the j sounds almost like a soft "k," and in some places it sounds very close to the "h" sound in words such as "hot" or "hero," although perhaps aspirated a bit more strongly. If you give the j the sound of the English "h" you will be understood, but keep in mind that is only an approximate sound.
You can hear the g and j sounds in our audio lesson on g and j. Words or phrases spoken by native speakers in the lesson are mucho gusto, fogón, fijaron, hijito and trabajo.