Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for react-router4 and multiple analytics accounts #69

Open
vijayyadav06 opened this issue Apr 30, 2018 · 1 comment
Open

Support for react-router4 and multiple analytics accounts #69

vijayyadav06 opened this issue Apr 30, 2018 · 1 comment
Labels

Comments

@vijayyadav06
Copy link

Thanks for providing the module. Have two questions -

  1. Wondering if react-tracking supports react-router4? We wish to track page view events.
  2. Can module support use of multiple simultaneous analytics accounts (say different google analytics accounts)? Useful for sites that has multi-tenants each tracking their own analytics.
@tizmagik
Copy link
Collaborator

tizmagik commented May 17, 2018

Hi @vijayyadav06 thanks for the question! Sorry for the late response here :)

  1. Yes, I don't see why RRv4 wouldn't be supported. Page View events can be triggered on "page components" componentDidMount() lifecycle method either via using the dispatchOnMount behavior, or by defining a top-level process function that can achieve the same result. More details on this in the main README.

If you've tried it out and are having any issues with RRv4 would love to hear about them. Feel free to follow-up to this issue or create a new one with some more details.

  1. Yes, since you ultimately have control over what happens to the tracking data you can opt to have it go anywhere, even running your own logic to control what happens depending on what the data looks like.

For example, your dispatch function could look something like this:

export default function dispatch(data) {
  const dataLayer = data.analyticAccount || 'dataLayer';
  (window[dataLayer] = window[dataLayer] || []).push(data);
}

And then you can define which analytic account to use wherever appropriate in your tree:

@track({ analyticAccount: 'dataLayer-2' })
class Foo extends Component { ... }

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants