Skip to content

Commit b479c60

Browse files
committed
removed utm and referrer from identify events
1 parent 8f59cec commit b479c60

File tree

4 files changed

+41
-33
lines changed

4 files changed

+41
-33
lines changed

amplitude.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Amplitude.prototype.init = function(apiKey, opt_userId, opt_config, callback) {
260260
log(e);
261261
}
262262

263-
if (callback && typeof(callback) === 'function') {
263+
if (callback && type(callback) === 'function') {
264264
callback();
265265
}
266266
};
@@ -508,7 +508,7 @@ var _truncateValue = function(value) {
508508
* Private logEvent method. Keeps apiProperties from being publicly exposed.
509509
*/
510510
Amplitude.prototype._logEvent = function(eventType, eventProperties, apiProperties, userProperties, callback) {
511-
if (typeof callback !== 'function') {
511+
if (type(callback) !== 'function') {
512512
callback = null;
513513
}
514514

@@ -536,16 +536,18 @@ Amplitude.prototype._logEvent = function(eventType, eventProperties, apiProperti
536536
this._lastEventTime = eventTime;
537537
localStorage.setItem(LocalStorageKeys.LAST_EVENT_TIME, this._lastEventTime);
538538

539-
// Add the utm properties, if any, onto the user properties.
540539
userProperties = userProperties || {};
541-
object.merge(userProperties, this._utmProperties);
542-
543-
// Add referral info onto the user properties
544-
if (this.options.includeReferrer) {
545-
object.merge(userProperties, {
546-
'referrer': this._getReferrer(),
547-
'referring_domain': this._getReferringDomain()
548-
});
540+
// Only add utm properties to user properties for events
541+
if (eventType !== IDENTIFY_EVENT) {
542+
object.merge(userProperties, this._utmProperties);
543+
544+
// Add referral info onto the user properties
545+
if (this.options.includeReferrer) {
546+
object.merge(userProperties, {
547+
'referrer': this._getReferrer(),
548+
'referring_domain': this._getReferringDomain()
549+
});
550+
}
549551
}
550552

551553
apiProperties = apiProperties || {};

amplitude.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/amplitude.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Amplitude.prototype.init = function(apiKey, opt_userId, opt_config, callback) {
148148
log(e);
149149
}
150150

151-
if (callback && typeof(callback) === 'function') {
151+
if (callback && type(callback) === 'function') {
152152
callback();
153153
}
154154
};
@@ -396,7 +396,7 @@ var _truncateValue = function(value) {
396396
* Private logEvent method. Keeps apiProperties from being publicly exposed.
397397
*/
398398
Amplitude.prototype._logEvent = function(eventType, eventProperties, apiProperties, userProperties, callback) {
399-
if (typeof callback !== 'function') {
399+
if (type(callback) !== 'function') {
400400
callback = null;
401401
}
402402

@@ -424,16 +424,18 @@ Amplitude.prototype._logEvent = function(eventType, eventProperties, apiProperti
424424
this._lastEventTime = eventTime;
425425
localStorage.setItem(LocalStorageKeys.LAST_EVENT_TIME, this._lastEventTime);
426426

427-
// Add the utm properties, if any, onto the user properties.
428427
userProperties = userProperties || {};
429-
object.merge(userProperties, this._utmProperties);
430-
431-
// Add referral info onto the user properties
432-
if (this.options.includeReferrer) {
433-
object.merge(userProperties, {
434-
'referrer': this._getReferrer(),
435-
'referring_domain': this._getReferringDomain()
436-
});
428+
// Only add utm properties to user properties for events
429+
if (eventType !== IDENTIFY_EVENT) {
430+
object.merge(userProperties, this._utmProperties);
431+
432+
// Add referral info onto the user properties
433+
if (this.options.includeReferrer) {
434+
object.merge(userProperties, {
435+
'referrer': this._getReferrer(),
436+
'referring_domain': this._getReferringDomain()
437+
});
438+
}
437439
}
438440

439441
apiProperties = apiProperties || {};

test/amplitude.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,15 +1126,11 @@ describe('Amplitude', function() {
11261126
amplitude.setUserProperties({user_prop: true});
11271127
assert.lengthOf(server.requests, 1);
11281128
var events = JSON.parse(querystring.parse(server.requests[0].requestBody).e);
1129+
// identify event should not have utm properties
11291130
assert.deepEqual(events[0].user_properties, {
11301131
'$set': {
11311132
'user_prop': true
1132-
},
1133-
utm_campaign: 'new',
1134-
utm_content: 'top',
1135-
utm_medium: 'email',
1136-
utm_source: 'amplitude',
1137-
utm_term: 'terms'
1133+
}
11381134
});
11391135
server.respondWith('success');
11401136
server.respond();
@@ -1226,17 +1222,25 @@ describe('Amplitude', function() {
12261222
});
12271223
});
12281224

1229-
it('should add referrer data to the user properties', function() {
1225+
it('should add referrer data to the user properties on events only', function() {
12301226
reset();
12311227
amplitude.init(apiKey, undefined, {includeReferrer: true});
12321228

12331229
amplitude.setUserProperties({user_prop: true});
1234-
assert.lengthOf(server.requests, 1);
1230+
assert.lengthOf(server.requests, 1);
12351231
var events = JSON.parse(querystring.parse(server.requests[0].requestBody).e);
12361232
assert.deepEqual(events[0].user_properties, {
12371233
$set: {
12381234
'user_prop': true
1239-
},
1235+
}
1236+
});
1237+
server.respondWith('success');
1238+
server.respond();
1239+
1240+
amplitude.logEvent('Referrer test event');
1241+
assert.lengthOf(server.requests, 2);
1242+
var events = JSON.parse(querystring.parse(server.requests[1].requestBody).e);
1243+
assert.deepEqual(events[0].user_properties, {
12401244
referrer: 'https://amplitude.com/contact',
12411245
referring_domain: 'amplitude.com'
12421246
});

0 commit comments

Comments
 (0)