ampproject / ampproject/amphtml

amp-amazon-onetag: Amazon affiliate links

Open
#23,166 25 comments 1 reaction 1 assignee Claimed by @lannka View on GitHub
INTENT TO IMPLEMENT P2: Soon Stale WG: monetization
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## What's the issue?

Its a feature request. I'm part of Amazon's Affiliate Marketing team. Amazon affiliate marketing is a channel that helps the content creators monetize their content by paying a fraction of profit for purchases from traffic coming from their websites.

We've a script called OneTag, which associate can add to their pages. Some benefits of OneTag script are:
1. It tags the amazon links on the page automatically which ensures that any click coming to amazon is attributed to the associate.
2. It provides feature to redirect the user clicking the link to amazon retail store based on the geo location of the user.
3. Provides data to associates to give them insight into their content performance.

We've observed a high adoption of Amazon associates on AMP pages and as a result we'd like to add the support for OneTag script on Amp pages.

**Sample code:**
```javascript

export class AmpAmazonOnetag extends AMP.BaseElement {
/** @param {!AmpElement} element */
constructor(element) {
super(element);
this.document = element.ownerDocument;
}

/** @override */
buildCallback() {
const onetagEndpoints = new Map();
onetagEndpoints.set("US", "z-na.associates-amazon.com");
onetagEndpoints.set("GB", "z-eu.associates-amazon.com");

var marketplace = this.element.getAttribute('marketplace');
var instanceID = this.element.getAttribute('instanceID');
if (onetagEndpoints.has(marketplace)) {
var scriptURL = "https://" + onetagEndpoints.get(marketplace) + "/widgets/onejs?MarketPlace=" + marketplace + "&adInstanceId=" + instanceID;
loadScript(this, scriptURL);
}
}

/** @override */
isLayoutSupported(layout) {
return layout == Layout.NODISPLAY;
}
}

AMP.extension('amp-amazon-onetag', '0.1', AMP => {
AMP.registerElement('amp-amazon-onetag', AmpAmazonOnetag);
});
```
**Example:**
```html


amp-amazon-onetag example





Sample Amazon link

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.