In Google's case (as in your example) it's incredibly easy: money is generated where a human being (a user) clicks on an add and thus generates ad dollars. If a German user clicks on it, money is generated in Germany.
It's the same with physical sales. If a customer buys something (from say a Chinese company) in France, then money is generated in France.