JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 41
  • Score
    100M100P100Q66964F
  • License MIT

A platform agnostic tool to quickly add affiliate links onto your website

Package Exports

  • affiliate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (affiliate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Affiliate

Affiliate is a platform agnostic link affiliator. Simplify affiliating links with automatic affiliation in the browser. Affiliate works with libraries that mutate the DOM after the page loads, including React.

Star me on Github Download via NPM Bundle small when minified Bundle small when minified and gunzipped

Installation

$ npm i -S affiliate
$ yarn add affiliate
$ bower install -S affiliate

Or use the Unpkg CDN

<script src="https://unpkg.com/affiliate@latest/dist/affiliate.js"></script>

For blogs who want Amazon affiliation

<script data-aff="amazon.com, www.amazon.com : tag = MY-AMAZON-TAG" src="https://unpkg.com/affiliate@1.2.x/dist/affiliate.js" async id="aff-js"></script>

What It Can Do

Affiliate can modify the following link into any of the others.

<a href="https://example.com/shop/product/item-id">Original</a>
<a href="https://example.com/shop/product/item-id?ref=my-tag">New Query Tags</a>
<a href="https://example.com/shop/product/item-id/ref/my-tag">Modified URL Path</a>
<a href="https://my-tag.example.com/shop/product/item-id">Modified Host Name</a>

Affiliate has easy plugins, such as one for Amazon, which simplify adding affiliate links even more.

Basic Setup

Read the documentation for more advanced usage.

// var Affiliate = require('affiliate');
var aff = Affiliate({
    tags: [
        {
            hosts: ['example.com', 'www.example.com'],
            query: {
                ref: 'my-tag' // ?ref=my-tag
            }
        },
        {
            hosts: ['example.org', 'shop.example.org'],
            query: {
                tag: 'my-tag2' // ?tag=my-tag2
            }
        }
    ]
});
aff.attach();

Documentation

Affiliate is simple and quick to set up, even for more complex usage. Read the docs at: affiliate.js.org.

A simplified code-less solution might better suit some blogging-style sites.

Insert this code into the page <head>. The contents of the data-aff attribute will tell Affiliate what to do.

<script data-aff="amazon.com, www.amazon.com : tag = MY-AMAZON-TAG" src="https://unpkg.com/affiliate@1.2.x/dist/affiliate.js" async id="aff-js"></script>

data-aff Syntax

The syntax for data-aff is a comma separated list of domains, colon, then comma separated list of tags in the format key=value. Multiple website groups can be separated by an exclamation mark.

amazon.com, www.amazon.com : tag = MY-AMAZON-TAG ! example.com, shop.example.com : ref = MY-OTHER-TAG

Testing

Affiliate is tested using Jasmine. The test of the minified packages is available here and the webpack package here.

Big Thanks

Sauce Labs

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs!

Star This Project

'Cause if you liked it then you should have put a star on it. 😉

License

MIT (C) Russell Steadman. Learn more in the LICENSE file.

Support Me

Like this project? Buy me a cup of coffee. ☕ Here are more of my projects.