This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
253 lines (190 loc) · 8.87 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!doctype html>
<html lang="en">
<head>
<title>Scrooge JS - Automatic Affiliate/Referral Linking</title>
<style type="text/css" media="screen">
body{
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 17px;
background: #ddd;
margin: 0;
padding: 0;
}
a{
text-decoration: none;
color: #257ad2;
}
a:hover{
text-decoration: underline;
}
a:visited{
color: #1e5cb3;
}
#content{
background: #fff;
padding: 20px;
width: 940px;
margin: 0 auto;
}
pre{
padding: 5px;
overflow: auto;
background: #f0f0f0;
border: 1px solid #ddd;
}
code{
background: #f0f0f0;
}
li code{
font-size: 14px;
}
h1{
margin-top: 0;
}
</style>
</head>
<body>
<div id="content">
<h1>Scrooge JS</h1>
<p>A Javascript tool for adding referral information to correspondent links. Supports any affiliate that just needs a parameter added to the link (Eg. http://somesite.com/product-1234/?ref={YOUR-REFERRAL-ID}). It also supports affiliate links through Commission Junction, it detects supported sites and replaces the link 'href' tag with the corresponding URL.</p>
<h2>Index</h2>
<ol>
<li><p><a href="#usage">Usage</a></p></li>
<li><p><a href="#api">Api</a></p></li>
<li><p><a href="#demo">Demo</a></p></li>
</ol>
<h2 id="usage">Usage</h2>
<ol>
<li><p>Include Scrooge.js in your <code>head</code>:</p>
<pre><code><script src="js/scrooge.js"></script></code></pre></li>
<li><p>Configure Scrooge inside a <code><script></code> tag after including it:</p>
<pre><code><script>
Scrooge.setAffiliateId('amazon', '{YOUR-AFFILIATE-ID}')
.addSite('somesite', 'ref', '{YOUR-AFFILIATE-ID}')
.addCjSite('zappos', 'zappos.com', '{YOUR-AFFILIATE-ID}', '{MERCHANT-ID}');
</script></code></pre></li>
<li><p>You're done.</p></li>
</ol>
<h2 id="api">API</h2>
<h3>Scrooge.start()</h3>
<p>Runs Scrooge and replaces every detected affiliate URL. You don't have to manually call it this method is run when the page is loaded. You can manually trigger the replacement after a DOM manipulation to detect and replace the new links.</p>
<h3>Scrooge.setContext(context)</h3>
<p>By default Scrooge searches for affiliate URLs in the whole document but if you want to limit the URL replacement to just the links inside an element you can use this method.</p>
<h4>Parameters</h4>
<ul>
<li><code>context</code> - <strong>String</strong> or <strong>DOM element</strong>.</li>
</ul>
<h4>Example usage</h4>
<pre><code>// Setting the context to a particular element with the id 'article'.
Scrooge.setContext('#article');
// Setting the context to a particular DOM element.
Scrooge.setContext(window.article);</code></pre>
<h3>Scrooge.addSite(key, domain, parameter_name, affiliate_id)</h3>
<p>Adds an affiliate site for url detection and replacement.</p>
<h4>Parameters</h4>
<ul>
<li><code>key</code> - <strong>String</strong>, a key or id used internally by Scrooge to identify each affiliate.</li>
<li><code>domain</code> - <strong>String</strong>, the domain that will be searched in links to add the affiliate information.</li>
<li><code>parameter_name</code> - <strong>String</strong>, the name of the parameter that will be added to the url.</li>
<li><code>affiliate_id</code> - <strong>String</strong>, your affiliate id.</li>
</ul>
<h4>Example usage</h4>
<pre><code>// Adding iTunes as an affiliate
Scrooge.addSite('itunes', 'itunes.apple.com', 'affId', '{YOUR-AFFILIATE-ID}');</code></pre>
<h3>Scrooge.addCjSite(key, domain, affiliate_id, merchant_id)</h3>
<p>Adds an affiliate site that works throught the Commision Junction referral system.</p>
<h4>Parameters</h4>
<ul>
<li><code>key</code> - <strong>String</strong>, a key or id used internally by Scrooge to identify each affiliate.</li>
<li><code>domain</code> - <strong>String</strong>, the domain that will be searched in links to add the affiliate information.</li>
<li><code>affiliate_id</code> - <strong>String</strong>, your CJ affiliate id (PID).</li>
<li><code>merchant_id</code> - <strong>String</strong>, the merchant link id (AID).</li>
</ul>
<h3>Scrooge.removeSite(key)</h3>
<p>Removes an affiliate site by its key.</p>
<h4>Parameters</h4>
<ul>
<li><code>key</code> - <strong>String</strong>, the key for the site that will be removed.</li>
</ul>
<h3>Scrooge.removeCjSite(key)</h3>
<p>Removes an affiliate site from Commission Junction by its key.</p>
<h4>Parameters</h4>
<ul>
<li><code>key</code> - <strong>String</strong>, the key for the site that will be removed.</li>
</ul>
<h3>Tips and Tricks</h3>
<ul>
<li><p>Every method returns an instance to the Scrooge object so every method is chainable:</p>
<pre><code>Scrooge.addSite().addCjSite().setAffiliateId();</code></pre></li>
<li><p>For Commission Junction you'll need the following information:</p>
<ul>
<li>PID (Affiliate ID): In the cj.com admin area: Account > Web Site Settings > PID</li>
<li>AID (Advertiser ID): The Advertiser/Merchant ID can be found by opening the Get Links of any active advertiser.</li>
</ul></li>
</ul>
<h2 id="demo">Demo</h2>
<h3>Javascript Code</h3>
<pre><code><script src="js/scrooge.js"></script>
<script>
// Setting the context to search only inside an element with a 'detect' id
Scrooge.setContext('#detect')
// Adding support for amazon.com links
.addSite('amazon', 'amazon.*', 'tag', 'httpmariec-20')
// Adding support for iTunes links
.addSite('itunes', 'itunes.apple.com', 'affId', 'TEST')
// Adding support for newegg.com through Commmission Junction
.addCjSite('newegg', 'newegg.com', '4858864', '10440897')
// Adding support for a fictitous site
.addSite('somesite', 'somesite.com', 'referral', 'YOUR-REFERRAL-ID');
</script></code></pre>
<h3>HTML Code</h3>
<pre><code><ul id="detect">
<li><a href="https://www.amazon.com/Western-Digital-Scorpio-Notebook-WD3200BEKT/dp/B001CO3EKQ/ref=sr_1_2?ie=UTF8&qid=1299021901&sr=8-2">Scorpio Black (Amazon)</a></li>
<li><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822136831&cm_re=wd_tv_live-_-22-136-831-_-Product">WD TV Live Hub Media Center (Newegg)</a></li>
<li><a href="http://www.somesite.com/product/1234/">Dummy Site</a></li>
<li><a href="http://itunes.apple.com/us/app/isaac-newtons-gravity/id345439503?mt=8">Isaac Newton's Gravity [iTunes]</a></li>
</ul></code></pre>
<h4>Detected and replaced</h4>
<ul id="detect">
<li><a href="https://www.amazon.co.uk/Western-Digital-Scorpio-Notebook-WD3200BEKT/dp/B001CO3EKQ/ref=sr_1_2?ie=UTF8&qid=1299021901&sr=8-2">Scorpio Black (Amazon)</a></li>
<li><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822136831&cm_re=wd_tv_live-_-22-136-831-_-Product">WD TV Live Hub Media Center (Newegg)</a></li>
<li><a href="http://www.somesite.com/product/1234/">Dummy Site</a></li>
<li><a href="http://itunes.apple.com/us/app/isaac-newtons-gravity/id345439503?mt=8">Isaac Newton's Gravity [iTunes]</a></li>
</ul>
<h4>Not detected because is out of the Scrooge detection context</h4>
<ul id="no_detect">
<li><a href="https://www.amazon.com/Western-Digital-Scorpio-Notebook-WD3200BEKT/dp/B001CO3EKQ/ref=sr_1_2?ie=UTF8&qid=1299021901&sr=8-2">Scorpio Black (Amazon)</a></li>
<li><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16822136831&cm_re=wd_tv_live-_-22-136-831-_-Product">WD TV Live Hub Media Center (Newegg)</a></li>
<li><a href="http://www.somesite.com/product/1234/">Dummy Site</a></li>
<li><a href="http://itunes.apple.com/us/app/isaac-newtons-gravity/id345439503?mt=8">Isaac Newton's Gravity [iTunes]</a></li>
</ul>
<script src="scrooge.js"></script>
<script>
// Setting the context to search only inside an element with a 'detect' id
Scrooge.setContext('#detect')
// Adding support for amazon.com links
.addSite('amazon', 'amazon.*', 'tag', 'httpmariec-20')
// Adding support for iTunes links
.addSite('itunes', 'itunes.apple.com', 'affId', 'TEST')
// Adding support for newegg.com through Commmission Junction
.addCjSite('newegg', 'newegg.com', '4858864', '10440897')
// Adding support for a fictitous site
.addSite('somesite', 'somesite.com', 'referral', 'YOUR-REFERRAL-ID');
</script>
</div>
<!-- !Google Tracking -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1804175-7']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</body>
</html>