SFI has an existing system that does this.
The "Hit Tracking" page on your Power Tools is an effective way to track your gateway hits.
Set key codes on each of the gateways you are using on your advertising. Just make sure you use only one key code on each advertising and you will be able to track which affiliate came from which advertising.