Skip to content

Commit cf85d1b

Browse files
committed
rename setRevenueProperties to setEventProperties
1 parent a066ff9 commit cf85d1b

17 files changed

+69
-68
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This Readme will guide you through using Amplitude's Javascript SDK to track use
1717
s.parentNode.insertBefore(r,s);function i(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
1818
return this}}var o=function(){this._q=[];return this};var a=["add","append","clearAll","prepend","set","setOnce","unset"];
1919
for(var u=0;u<a.length;u++){i(o,a[u])}n.Identify=o;var c=function(){this._q=[];return this;
20-
};var p=["setProductId","setQuantity","setPrice","setRevenueType","setRevenueProperties"];
20+
};var p=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
2121
for(var l=0;l<p.length;l++){i(c,p[l])}n.Revenue=c;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","logRevenueV2"];
2222
function v(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
2323
}}for(var n=0;n<d.length;n++){t(d[n])}}v(n);e.amplitude=n})(window,document);
@@ -185,7 +185,7 @@ amplitude.clearUserProperties();
185185

186186
# Tracking Revenue #
187187

188-
The preferred method of tracking revenue for a user now is to use `logRevenueV2()` in conjunction with the provided `Revenue` interface. `Revenue` instances will store each revenue transaction and allow you to define several special revenue properties (such as revenueType, productId, etc) that are used in Amplitude dashboard's Revenue tab. You can now also add event properties to the revenue event, via the revenueProperties field. These `Revenue` instance objects are then passed into `logRevenueV2` to send as revenue events to Amplitude servers. This allows us to automatically display data relevant to revenue on the Amplitude website, including average revenue per daily active user (ARPDAU), 1, 7, 14, 30, 60, and 90 day revenue, lifetime value (LTV) estimates, and revenue by advertising campaign cohort and daily/weekly/monthly cohorts.
188+
The preferred method of tracking revenue for a user now is to use `logRevenueV2()` in conjunction with the provided `Revenue` interface. `Revenue` instances will store each revenue transaction and allow you to define several special revenue properties (such as revenueType, productId, etc) that are used in Amplitude dashboard's Revenue tab. You can now also add event properties to the revenue event, via the eventProperties field. These `Revenue` instance objects are then passed into `logRevenueV2` to send as revenue events to Amplitude servers. This allows us to automatically display data relevant to revenue on the Amplitude website, including average revenue per daily active user (ARPDAU), 1, 7, 14, 30, 60, and 90 day revenue, lifetime value (LTV) estimates, and revenue by advertising campaign cohort and daily/weekly/monthly cohorts.
189189
190190
Each time a user generates revenue, you create a `Revenue` object and fill out the revenue properties:
191191
```javascript
@@ -201,9 +201,9 @@ amplitude.logRevenueV2(revenue);
201201
| quantity | Integer | Required: the quantity of products purchased. Defaults to 1 if not specified. Revenue = quantity * price | 1 |
202202
| price | Double | Required: the price of the products purchased (can be negative). Revenue = quantity * price | null |
203203
| revenueType | String | Optional: the type of revenue (ex: tax, refund, income) | null |
204-
| revenueProperties | Object | Optional: an object of event properties to include in the revenue event | null |
204+
| eventProperties | Object | Optional: an object of event properties to include in the revenue event | null |
205205
206-
Note: the price can be negative, which might be useful for tracking revenue lost, for example refunds or costs.
206+
Note: the price can be negative, which might be useful for tracking revenue lost, for example refunds or costs. Also note, you can set event properties on the revenue event just as you would with logEvent by passing in a object of string key value pairs. These event properties, however, will only appear in the Event Segmentation tab, not in the Revenue tab.
207207
208208
### Backwards compatibility ###
209209

amplitude-segment-snippet.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}var s=function(){
33
this._q=[];return this};var i=["add","append","clearAll","prepend","set","setOnce","unset"];
44
for(var o=0;o<i.length;o++){n(s,i[o])}r.Identify=s;var a=function(){this._q=[];return this;
5-
};var u=["setProductId","setQuantity","setPrice","setRevenueType","setRevenueProperties"];
5+
};var u=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
66
for(var c=0;c<u.length;c++){n(a,u[c])}r.Revenue=a;var l=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","logRevenueV2"];
77
function p(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
88
}}for(var r=0;r<l.length;r++){t(l[r])}}p(r);e.amplitude=r})(window,document);

amplitude-snippet.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ r.onload=function(){e.amplitude.runQueuedFunctions()};var s=t.getElementsByTagNa
44
s.parentNode.insertBefore(r,s);function i(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
55
return this}}var o=function(){this._q=[];return this};var a=["add","append","clearAll","prepend","set","setOnce","unset"];
66
for(var u=0;u<a.length;u++){i(o,a[u])}n.Identify=o;var c=function(){this._q=[];return this;
7-
};var p=["setProductId","setQuantity","setPrice","setRevenueType","setRevenueProperties"];
7+
};var p=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
88
for(var l=0;l<p.length;l++){i(c,p[l])}n.Revenue=c;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","logRevenueV2"];
99
function v(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
1010
}}for(var n=0;n<d.length;n++){t(d[n])}}v(n);e.amplitude=n})(window,document);

amplitude.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,17 +3380,17 @@ Revenue.prototype.setRevenueType = function setRevenueType(revenueType) {
33803380
/**
33813381
* Set event properties for the revenue event.
33823382
* @public
3383-
* @param {object} properties - Revenue event properties to set.
3383+
* @param {object} eventProperties - Revenue event properties to set.
33843384
* @return {Revenue} Returns the same Revenue object, allowing you to chain multiple method calls together.
33853385
* @example var event_properties = {'city': 'San Francisco'};
3386-
* var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setRevenueProperties(event_properties);
3386+
* var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setEventProperties(event_properties);
33873387
* amplitude.logRevenueV2(revenue);
33883388
*/
3389-
Revenue.prototype.setRevenueProperties = function setRevenueProperties(revenueProperties) {
3390-
if (type(revenueProperties) !== 'object') {
3391-
utils.log('Unsupported type for revenueProperties: ' + type(revenueProperties) + ', expecting object');
3389+
Revenue.prototype.setEventProperties = function setEventProperties(eventProperties) {
3390+
if (type(eventProperties) !== 'object') {
3391+
utils.log('Unsupported type for eventProperties: ' + type(eventProperties) + ', expecting object');
33923392
} else {
3393-
this._properties = utils.validateProperties(revenueProperties);
3393+
this._properties = utils.validateProperties(eventProperties);
33943394
}
33953395
return this;
33963396
};

amplitude.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/Amplitude.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2483,7 +2483,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
24832483
<br class="clear">
24842484

24852485
<footer>
2486-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Apr 19 2016 17:19:27 GMT-0700 (PDT)
2486+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Apr 20 2016 00:37:56 GMT-0700 (PDT)
24872487
</footer>
24882488

24892489
<script> prettyPrint(); </script>

documentation/Identify.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
12951295
<br class="clear">
12961296

12971297
<footer>
1298-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Apr 19 2016 17:19:27 GMT-0700 (PDT)
1298+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Apr 20 2016 00:37:56 GMT-0700 (PDT)
12991299
</footer>
13001300

13011301
<script> prettyPrint(); </script>

documentation/Revenue.html

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,14 @@ <h3 class="subsection-title">Methods</h3>
151151

152152

153153

154-
<h4 class="name" id="setPrice"><span class="type-signature"></span>setPrice<span class="signature">(price)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
154+
<h4 class="name" id="setEventProperties"><span class="type-signature"></span>setEventProperties<span class="signature">(eventProperties)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
155155

156156

157157

158158

159159

160160
<div class="description">
161-
Set a value for the price. This field is required for all revenue being logged.
162-
Note revenue amount is calculated as price * quantity.
161+
Set event properties for the revenue event.
163162
</div>
164163

165164

@@ -195,13 +194,13 @@ <h5>Parameters:</h5>
195194

196195
<tr>
197196

198-
<td class="name"><code>price</code></td>
197+
<td class="name"><code>eventProperties</code></td>
199198

200199

201200
<td class="type">
202201

203202

204-
<span class="param-type">number</span>
203+
<span class="param-type">object</span>
205204

206205

207206

@@ -211,7 +210,7 @@ <h5>Parameters:</h5>
211210

212211

213212

214-
<td class="description last">Double value for the quantity.</td>
213+
<td class="description last">Revenue event properties to set.</td>
215214
</tr>
216215

217216

@@ -252,7 +251,7 @@ <h5>Parameters:</h5>
252251

253252
<dt class="tag-source">Source:</dt>
254253
<dd class="tag-source"><ul class="dummy"><li>
255-
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line78">line 78</a>
254+
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line113">line 113</a>
256255
</li></ul></dd>
257256

258257

@@ -301,7 +300,8 @@ <h5>Returns:</h5>
301300

302301
<h5>Example</h5>
303302

304-
<pre class="prettyprint"><code>var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99);
303+
<pre class="prettyprint"><code>var event_properties = {'city': 'San Francisco'};
304+
var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setEventProperties(event_properties);
305305
amplitude.logRevenueV2(revenue);</code></pre>
306306

307307

@@ -311,14 +311,15 @@ <h5>Example</h5>
311311

312312

313313

314-
<h4 class="name" id="setProductId"><span class="type-signature"></span>setProductId<span class="signature">(productId)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
314+
<h4 class="name" id="setPrice"><span class="type-signature"></span>setPrice<span class="signature">(price)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
315315

316316

317317

318318

319319

320320
<div class="description">
321-
Set a value for the product identifer. This field is required for all revenue being logged.
321+
Set a value for the price. This field is required for all revenue being logged.
322+
Note revenue amount is calculated as price * quantity.
322323
</div>
323324

324325

@@ -354,13 +355,13 @@ <h5>Parameters:</h5>
354355

355356
<tr>
356357

357-
<td class="name"><code>productId</code></td>
358+
<td class="name"><code>price</code></td>
358359

359360

360361
<td class="type">
361362

362363

363-
<span class="param-type">string</span>
364+
<span class="param-type">number</span>
364365

365366

366367

@@ -370,7 +371,7 @@ <h5>Parameters:</h5>
370371

371372

372373

373-
<td class="description last">The value for the product identifier. Empty and invalid strings are ignored.</td>
374+
<td class="description last">Double value for the quantity.</td>
374375
</tr>
375376

376377

@@ -411,7 +412,7 @@ <h5>Parameters:</h5>
411412

412413
<dt class="tag-source">Source:</dt>
413414
<dd class="tag-source"><ul class="dummy"><li>
414-
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line41">line 41</a>
415+
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line78">line 78</a>
415416
</li></ul></dd>
416417

417418

@@ -470,14 +471,14 @@ <h5>Example</h5>
470471

471472

472473

473-
<h4 class="name" id="setQuantity"><span class="type-signature"></span>setQuantity<span class="signature">(quantity)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
474+
<h4 class="name" id="setProductId"><span class="type-signature"></span>setProductId<span class="signature">(productId)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
474475

475476

476477

477478

478479

479480
<div class="description">
480-
Set a value for the quantity. Note revenue amount is calculated as price * quantity.
481+
Set a value for the product identifer. This field is required for all revenue being logged.
481482
</div>
482483

483484

@@ -513,13 +514,13 @@ <h5>Parameters:</h5>
513514

514515
<tr>
515516

516-
<td class="name"><code>quantity</code></td>
517+
<td class="name"><code>productId</code></td>
517518

518519

519520
<td class="type">
520521

521522

522-
<span class="param-type">number</span>
523+
<span class="param-type">string</span>
523524

524525

525526

@@ -529,7 +530,7 @@ <h5>Parameters:</h5>
529530

530531

531532

532-
<td class="description last">Integer value for the quantity. If not set, quantity defaults to 1.</td>
533+
<td class="description last">The value for the product identifier. Empty and invalid strings are ignored.</td>
533534
</tr>
534535

535536

@@ -570,7 +571,7 @@ <h5>Parameters:</h5>
570571

571572
<dt class="tag-source">Source:</dt>
572573
<dd class="tag-source"><ul class="dummy"><li>
573-
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line60">line 60</a>
574+
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line41">line 41</a>
574575
</li></ul></dd>
575576

576577

@@ -619,7 +620,7 @@ <h5>Returns:</h5>
619620

620621
<h5>Example</h5>
621622

622-
<pre class="prettyprint"><code>var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setQuantity(5);
623+
<pre class="prettyprint"><code>var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99);
623624
amplitude.logRevenueV2(revenue);</code></pre>
624625

625626

@@ -629,14 +630,14 @@ <h5>Example</h5>
629630

630631

631632

632-
<h4 class="name" id="setRevenueProperties"><span class="type-signature"></span>setRevenueProperties<span class="signature">(properties)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
633+
<h4 class="name" id="setQuantity"><span class="type-signature"></span>setQuantity<span class="signature">(quantity)</span><span class="type-signature"> &rarr; {<a href="Revenue.html">Revenue</a>}</span></h4>
633634

634635

635636

636637

637638

638639
<div class="description">
639-
Set event properties for the revenue event.
640+
Set a value for the quantity. Note revenue amount is calculated as price * quantity.
640641
</div>
641642

642643

@@ -672,13 +673,13 @@ <h5>Parameters:</h5>
672673

673674
<tr>
674675

675-
<td class="name"><code>properties</code></td>
676+
<td class="name"><code>quantity</code></td>
676677

677678

678679
<td class="type">
679680

680681

681-
<span class="param-type">object</span>
682+
<span class="param-type">number</span>
682683

683684

684685

@@ -688,7 +689,7 @@ <h5>Parameters:</h5>
688689

689690

690691

691-
<td class="description last">Revenue event properties to set.</td>
692+
<td class="description last">Integer value for the quantity. If not set, quantity defaults to 1.</td>
692693
</tr>
693694

694695

@@ -729,7 +730,7 @@ <h5>Parameters:</h5>
729730

730731
<dt class="tag-source">Source:</dt>
731732
<dd class="tag-source"><ul class="dummy"><li>
732-
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line113">line 113</a>
733+
<a href="revenue.js.html">revenue.js</a>, <a href="revenue.js.html#line60">line 60</a>
733734
</li></ul></dd>
734735

735736

@@ -778,8 +779,7 @@ <h5>Returns:</h5>
778779

779780
<h5>Example</h5>
780781

781-
<pre class="prettyprint"><code>var event_properties = {'city': 'San Francisco'};
782-
var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setRevenueProperties(event_properties);
782+
<pre class="prettyprint"><code>var revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setQuantity(5);
783783
amplitude.logRevenueV2(revenue);</code></pre>
784784

785785

@@ -965,7 +965,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
965965
<br class="clear">
966966

967967
<footer>
968-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Apr 19 2016 17:19:27 GMT-0700 (PDT)
968+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Apr 20 2016 00:37:56 GMT-0700 (PDT)
969969
</footer>
970970

971971
<script> prettyPrint(); </script>

documentation/amplitude.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
10931093
<br class="clear">
10941094

10951095
<footer>
1096-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Apr 19 2016 17:19:27 GMT-0700 (PDT)
1096+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Apr 20 2016 00:37:56 GMT-0700 (PDT)
10971097
</footer>
10981098

10991099
<script> prettyPrint(); </script>

documentation/identify.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
226226
<br class="clear">
227227

228228
<footer>
229-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Apr 19 2016 17:19:27 GMT-0700 (PDT)
229+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Apr 20 2016 00:37:56 GMT-0700 (PDT)
230230
</footer>
231231

232232
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)