{"id":16171223,"url":"https://github.com/loevgaard/last-source","last_synced_at":"2025-04-07T07:49:57.792Z","repository":{"id":58237181,"uuid":"83436863","full_name":"loevgaard/last-source","owner":"loevgaard","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-07T13:38:39.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T12:05:37.717Z","etag":null,"topics":["affiliates","javascript","js"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loevgaard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-28T13:39:53.000Z","updated_at":"2017-11-30T14:10:35.000Z","dependencies_parsed_at":"2022-08-31T03:01:52.215Z","dependency_job_id":null,"html_url":"https://github.com/loevgaard/last-source","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loevgaard%2Flast-source","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loevgaard%2Flast-source/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loevgaard%2Flast-source/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loevgaard%2Flast-source/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loevgaard","download_url":"https://codeload.github.com/loevgaard/last-source/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615481,"owners_count":20967182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["affiliates","javascript","js"],"created_at":"2024-10-10T03:21:09.897Z","updated_at":"2025-04-07T07:49:57.766Z","avatar_url":"https://github.com/loevgaard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Last Source\nWith 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.\n\nWhen you include Last Source with\n\n```html\n\u003cscript src=\"/js/lastsource.js\"\u003e\u003c/script\u003e\n```\n\nthe `lastSource` object will be bound to the `window` object so you can do:\n\n```javascript\nif(lastSource.getLastSource() == \"your-affiliate's-code\") {\n    // inject tracking pixel\n}\n```\n\n## Example\nSay 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:\n\n```javascript\nif(lastSource.getLastSource() == 'partnerads') {\n    $('body').append('\u003cimg src=\"https://www.partner-ads.com/dk/leadtrack.php?programid=[program id]\u0026type=salg\u0026ordrenummer=[order id]\u0026varenummer=x\u0026antal=1\u0026omprsalg=[revenue]\" width=0 height=0 style=\"display:none\"\u003e');\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floevgaard%2Flast-source","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floevgaard%2Flast-source","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floevgaard%2Flast-source/lists"}