https://github.com/loevgaard/last-source
https://github.com/loevgaard/last-source
affiliates javascript js
Last synced: 12 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/loevgaard/last-source
- Owner: loevgaard
- License: mit
- Created: 2017-02-28T13:39:53.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-07T13:38:39.000Z (almost 9 years ago)
- Last Synced: 2025-03-13T12:05:37.717Z (about 1 year ago)
- Topics: affiliates, javascript, js
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Last Source
With Last Source enabled it is as easy as lastSource.getLastSource() to get the last source/referrer your visitor visited. This is very useful in affiliate programs where you want to pay your affiliate only if the last click to your website came from his website and not AdWords, your newsletter or any other source.
When you include Last Source with
```html
```
the `lastSource` object will be bound to the `window` object so you can do:
```javascript
if(lastSource.getLastSource() == "your-affiliate's-code") {
// inject tracking pixel
}
```
## Example
Say you use Partner Ads for affiliates, and you know that affiliates tag your links with utm_source=partnerads, then your javascript on your checkout page will look like this:
```javascript
if(lastSource.getLastSource() == 'partnerads') {
$('body').append('
');
}
```