-
Notifications
You must be signed in to change notification settings - Fork 2
Added framework for URL-change condition for virtualPage call #9
base: master
Are you sure you want to change the base?
Conversation
lib/index.js
Outdated
| var onBody = require('on-body'); | ||
|
|
||
| /** TO-DO: connect urlChanged to Segment URL-change event **/ | ||
| var urlChanged = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @noah-berman - the analytics.js api currently doesn't expose any kind of url change hook. Is there something else that you could reference to test for url changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option would be to store the value of window.location.href in a class property (called something like currentUrl) when initialize is called (which should only be when the DOM is refreshed). Then, inside page, check to see if window.location.href is equal to this.currentUrl. If not, then call virtualPage. If so, then do the regular page load logic.
| this.pageCalledYet = true; | ||
| this._initialize(); | ||
| } else { | ||
| } else if (this.options.trackGalleryClicksAsPageviews || urlChanged) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like the name of this option is very specific for user's that have image galleries. Are there potentially other types of sites that might use this feature?
|
@ccnixon you were correct in the window.location.href suggestion - just added that to the logic now. We do know of other sites where the major cause of pageview issues is specifically Gallery Clicks (understanding that it is an oddly specific thing to label as an option). If possible, in addition to naming it as such, a small blurb explaining what it does (e.g. "calls Chartbeat for all new pages regardless of page refresh or URL change") I believe would be sufficient. |
|
Hi @noah-berman, as part of the monorepo migration, this issue has been moved to new issue. Our engineers have been notified and will prioritize and work on it ASAP. Thank you! For more information, see README.md. |
Created new
optionvalue fortrackGalleryClicksAsPageviews, which should be added a toggle in the Segment UI. This creates an additional condition that only calls pSUPERFLY when the user has selected this toggle or if there has been an event that turnedurlChangedto true.TO-DO:
urlChangedto an actual URL change event within segment architecturetrackGalleryClicksAsPageviews