Update riveted.js with support for multiple simultaneous trackers#32
Open
jerclarke wants to merge 1 commit intorobflaherty:masterfrom
Open
Update riveted.js with support for multiple simultaneous trackers#32jerclarke wants to merge 1 commit intorobflaherty:masterfrom
jerclarke wants to merge 1 commit intorobflaherty:masterfrom
Conversation
The previous version supports multi-tracker setups with the `gaTracker` argument, which specifies a single tracker to which Riveted events will be sent. This is a bummer if you want several trackers to all receive the Riveted events so that they match (and since the data is useful everywhere). This patch adds support for sending events to several trackers: - `gaTracker` now allows both the old string format for a single tracker **and** array format to pass several trackers - `universalSendCommand` switches to array `universalSeldCommands` so it can contain commands for multiple trackers - `init` now processes `gaTracker` based on whether it's an array, (build commands for each tracker in the array), a string (build the single command for that tracker) or empty (build a command for the default tracker). - `sendUserTiming` and `sendEvent` now loop through the commands in `universalSendCommands` array to send events for each registered tracker Note that it also adds references to `default` tracker, which is a string used to indicate the main tracker that doesn't require a prefix for `ga` send commands. If you pass in multiple trackers via an array in `gaTracker` then you would use `default` to indicate that prefix-less tracker. We also made sure that if you pass in `default` as a string for a single tracker what happens is what you'd expect: The code for the prefix-less tracker is used. As far as we know this update is back-compatible with previous versions. If `gaTracker` is empty or a string with a single tracker, Riveted will work the same as before!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous version supports multi-tracker setups with the
gaTrackerargument, which specifies a single tracker to which Riveted events will be sent. This is a bummer if you want several trackers to all receive the Riveted events so that they match (and since the data is useful everywhere).This patch adds support for sending events to several trackers:
gaTrackernow allows both the old string format for a single tracker and array format to pass several trackersuniversalSendCommandswitches to arrayuniversalSeldCommandsso it can contain commands for multiple trackersinitnow processesgaTrackerbased on whether it's an array, (build commands for each tracker in the array), a string (build the single command for that tracker) or empty (build a command for the default tracker).sendUserTimingandsendEventnow loop through the commands inuniversalSendCommandsarray to send events for each registered trackerNote that it also adds references to
defaulttracker, which is a string used to indicate the main tracker that doesn't require a prefix forgasend commands. If you pass in multiple trackers via an array ingaTrackerthen you would usedefaultto indicate that prefix-less tracker. We also made sure that if you pass indefaultas a string for a single tracker what happens is what you'd expect: The code for the prefix-less tracker is used.As far as we know this update is back-compatible with previous versions. If
gaTrackeris empty or a string with a single tracker, Riveted will work the same as before!Thanks for considering this PR! If it can't be merged, I hope it can help someone else having the same problem as us (wanting Riveted on both of our trackers).