How to Make Money with the Amazon Associates Program
Amazon Affiliate Program provides different kinds of ads.
Native Shopping Ads
- amzn_assoc_placement should be unique.
- amzn_assoc_search_bar: false/true to whetehr show the search bar.
Custom Ads
Custom Ads allows us to curate specific products from Amazon that you would like to recommend and place the ad unit into your webpage. All we need is find a list ASINs of products and add them into amzn_assoc_asins.
<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_search_bar = "false";
amzn_assoc_tracking_id = "the_tracking_id";
amzn_assoc_ad_mode = "manual";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_title = "Best books for algorithms interview";
amzn_assoc_linkid = "the_amzn_assoc_linkid";
amzn_assoc_asins = "0984782850,1517671272,1617292230,032157351X,1537713949,0262033844,111941847X,819324527X";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
<div id="amzn-assoc-ad-19c89cc6-6f8f-485d-a31a-7bc49e98e831"></div><script async src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=19c89cc6-6f8f-485d-a31a-7bc49e98e831"></script>
Recommendation Ads
- Displays products related to your page content and visitors
- We can choose “Emphasize Categories”.
Search Ads
Display search results from Amazon.com by specifying a search phrase and selecting a relevant category to your page content in a responsive ad unit that works across screen sizes.
We can specify a list of search phrases and sort them by priority, random pick one search phrase and stick to it in the X(10) days.
<script type="text/javascript">
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function deleteCookie(name, path, domain) {
if (readCookie(name)) createCookie(name, "", -1, path, domain);
}
function pickOne(weightedPosts) {
var totalWeight = 0;
for (let post of weightedPosts) {
totalWeight += post.weight;
}
var randomWeight = Math.random() * totalWeight;
var currWeight = 0;
for (let post of weightedPosts) {
currWeight += post.weight;
if (currWeight > randomWeight) {
return post;
}
}
}
</script>
<script type="text/javascript">
var pos = readCookie("amazonItemPos")
var products = Array("iphone", "iPad Pro", "iPad Mini", "apple watch series 4", "MacBook Pro", "MacBook Air", "google pixel 3", "chromebook", "Amazon Echo");
var items = new Set();
var totalCount = products.length;
for (var i = 0; i < products.length; i++) {
items.add(
{
product: products[i],
weight: totalCount - i,
pos: i
}
);
}
// var item = items[Math.floor(Math.random() * items.length)];
if (pos == null || pos <0 || pos > products.length) {
// pos = Math.floor(Math.random() * items.length);
pos = pickOne(items).pos
createCookie("amazonItemPos", pos, 10);
}
var item = products[pos];
amzn_assoc_placement = "adunit3";
amzn_assoc_search_bar = "true";
amzn_assoc_tracking_id = "the_tracking_id";
amzn_assoc_search_bar_position = "bottom";
amzn_assoc_ad_mode = "search";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_region = "US";
amzn_assoc_title = "";
amzn_assoc_default_search_phrase = item;
amzn_assoc_default_category = "All";
amzn_assoc_linkid = "the_amzn_assoc_linkid";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
Tips
User Scripts to Change Html5 Video Player Speed
The Goal
I Would like to change the speed of HTML5 video player at pan.baidu.com, so I can spend less time on the video and finish it sooner.
The Implementation
I found some user script at greasyfork for Chrome with tampermonkey extension
- This one works but can only change the speed to 1.5X
- The other one doesn’t work, maybe due to the change of website
Based on these 2 script, I made the following simple user script that can change video speed to 1.5, 1.75, 2.0.
// ==UserScript==
// @name Change speed at pan.baidu
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Add button to change to 1.5, 1.76, 2X speed
// @author Jeffery Yuan
// @match *://*.pan.baidu.com/*
// @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js
// ==/UserScript==
(function() {
'use strict';
var $ = $ || window.$;
function addSpeedButton(parentNode, speed){
var cb = document.createElement("a");
cb.innerHTML='<a class="g-button" href="javascript:;" title="' + speed + '">'+
'<span class="g-button-right">'+
'<em class="icon icon-appeal" title="' + speed +'"></em>'+
'<span id="fps" class="text" style="width: auto;">' + speed + '</span></span></a>'
cb.onclick=function(){
videojs.getPlayers("video-player").html5player.tech_.setPlaybackRate(speed);
};
parentNode.after(cb);
}
// var tb = document.getElementsByClassName("g-button")[1];
var elms = document.getElementsByClassName("g-button");
var toolbar = elms[0].parentNode;
toolbar.removeChild(elms[1]);
toolbar.removeChild(elms[1]);
toolbar.removeChild(elms[1]);
var tb = elms[0];
addSpeedButton(tb, 2.0)
addSpeedButton(tb, 1.75)
addSpeedButton(tb, 1.5)
addSpeedButton(tb, 1)
})();
Other Ideas
- Able to resume playback of a video at the point in time it was left.