Using your example, if the chords are common to both C major and G major, you need to next look at the scale which the melody (or melodies) use. Is the F in the melody an
F natural (suggesting it is the 4th note in C major) or
F# (suggesting it is the 7th note in G Major). If you were to sub in a dominant 7th chord, would it sound more at home as the
V7 of C major (ie a
G7 chord) or as the
V7 of G major (ie
D7)? You can do a number of analyses like this, to try to work out purely with theory which is most likely. Another thing to keep in mind is that it might be a modal melody/sequence.
If no simple analyses work, you could have an argument for either key and spark a rather interesting debate, giving both arguments and discussing which you find most convincing based on the pros/cons. Does the song feel more like the melody resolves to a
C or a
G as the tonic note? In a song like Dreams by Fleetwood Mac, the only two chords are
F major and
G major, yet the melody suggests that the song feels like it is in
C major even though the song doesn't technically feature that chord anywhere (as far as I remember at least). Maybe the chord sequence you are analysing doesn't feature the
I chord at all.
At its heart, musical theory analysis is very subjective. There are commonly followed rules and opinions, but these can always be challenged. As long as you can convincingly justify yourself, you will have a leg to stand on regardless of what you might suggest as the "correct" analysis.