Skip to content

Commit 910cb8e

Browse files
authored
Merge pull request #81 from amplitude/session_referrer
Only capture utm and referrer once per session
2 parents 7759c2e + eff89a0 commit 910cb8e

15 files changed

+143
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Unreleased
22

33
* Update README with link to our [Google Tag Manager integration demo app](https://github.com/amplitude/GTM-Web-Demo).
4+
* Fix bug where referrer and UTM params were being captured more than once per session.
45

56
### 3.0.0 (May 27, 2016)
67

amplitude.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,14 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o
568568
if (!this._sessionId || !this._lastEventTime || now - this._lastEventTime > this.options.sessionTimeout) {
569569
this._newSession = true;
570570
this._sessionId = now;
571+
572+
// only capture UTM params and referrer if new session
573+
if (this.options.includeUtm) {
574+
this._initUtmData();
575+
}
576+
if (this.options.includeReferrer) {
577+
this._saveReferrer(this._getReferrer());
578+
}
571579
}
572580
this._lastEventTime = now;
573581
_saveCookieData(this);
@@ -594,14 +602,6 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o
594602

595603
this._sendEventsIfReady(); // try sending unsent events
596604
}
597-
598-
if (this.options.includeUtm) {
599-
this._initUtmData();
600-
}
601-
602-
if (this.options.includeReferrer) {
603-
this._saveReferrer(this._getReferrer());
604-
}
605605
} catch (e) {
606606
utils.log(e);
607607
} finally {

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.

documentation/Amplitude.html

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

31393139
<footer>
3140-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri May 27 2016 15:00:10 GMT-0700 (PDT)
3140+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
31413141
</footer>
31423142

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

documentation/AmplitudeClient.html

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

27932793
<footer>
2794-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri May 27 2016 15:00:10 GMT-0700 (PDT)
2794+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
27952795
</footer>
27962796

27972797
<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 Fri May 27 2016 15:00:10 GMT-0700 (PDT)
1298+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
12991299
</footer>
13001300

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

documentation/Revenue.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 Fri May 27 2016 15:00:10 GMT-0700 (PDT)
968+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
969969
</footer>
970970

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

documentation/amplitude-client.js.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
115115
if (!this._sessionId || !this._lastEventTime || now - this._lastEventTime > this.options.sessionTimeout) {
116116
this._newSession = true;
117117
this._sessionId = now;
118+
119+
// only capture UTM params and referrer if new session
120+
if (this.options.includeUtm) {
121+
this._initUtmData();
122+
}
123+
if (this.options.includeReferrer) {
124+
this._saveReferrer(this._getReferrer());
125+
}
118126
}
119127
this._lastEventTime = now;
120128
_saveCookieData(this);
@@ -141,14 +149,6 @@ <h1 class="page-title">Source: amplitude-client.js</h1>
141149

142150
this._sendEventsIfReady(); // try sending unsent events
143151
}
144-
145-
if (this.options.includeUtm) {
146-
this._initUtmData();
147-
}
148-
149-
if (this.options.includeReferrer) {
150-
this._saveReferrer(this._getReferrer());
151-
}
152152
} catch (e) {
153153
utils.log(e);
154154
} finally {
@@ -1170,7 +1170,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Amplitude
11701170
<br class="clear">
11711171

11721172
<footer>
1173-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri May 27 2016 15:00:10 GMT-0700 (PDT)
1173+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
11741174
</footer>
11751175

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

documentation/amplitude.js.html

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

411411
<footer>
412-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri May 27 2016 15:00:10 GMT-0700 (PDT)
412+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
413413
</footer>
414414

415415
<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 Fri May 27 2016 15:00:10 GMT-0700 (PDT)
229+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Wed Jun 22 2016 14:19:08 GMT-0700 (PDT)
230230
</footer>
231231

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

0 commit comments

Comments
 (0)