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

Analytics broken for Hubspot, Quantcast, Chartbeat, Comscore and KISSmetrics #108

Open
derouck opened this issue Apr 25, 2016 · 9 comments

Comments

@derouck
Copy link

derouck commented Apr 25, 2016

I tried to setup analytics with Google Analytics and Hubspot through the analytics. But for some reason which I don't get it Google Analytics is not receiving any data anymore once Hubspot tracking code is also setup.

If I leave out the Hubspot code from the settings then Google is working like a charm. Has anybody had this issue as well and is there a solution or is there a way to find out what's going wrong?

Thanks for pointing me in the right direction! I will also ask the Hubspot support team to have a look at it.

@rgould
Copy link
Contributor

rgould commented May 24, 2016

We'll try and take a look, but it sounds like it's maybe an analytics.js issue. I'd also triple check your settings.json file too!

@rgould rgould added the bug label May 24, 2016
@tsemana tsemana self-assigned this May 27, 2016
@derouck
Copy link
Author

derouck commented Jun 8, 2016

There seems to be a much bigger problem than I thought. Apparently the Hubspot code doesn't get initialized at all. The thing is that for quite a few libraries there is an option "assumesPageView". If this flag is set in the plugin code, like it is for HubSpot, initialization should happen when the first page call is made. This is implemented with the "after" package. This mechanism is written in wrapInitialize and wrapPage should cause the second initialize and final initialization.

But no page call is made in this case because initialization is not completed. Basically the problem is introduced with this commit: 4de2fd2

I could solve the issue for me by avoiding to use trackPageWhenReady, but this might introduce different problems. I don't know whether the changes with those on ready callbacks have been made out of another necessity?

I will update the issue title accordingly as this issue is much bigger than initially thought.

@derouck derouck changed the title Hubspot + Google Analytics Analytics broken for Hubspot, Quantcast, Chartbeat, Comscore and KISSmetrics Jun 8, 2016
@derouck
Copy link
Author

derouck commented Jun 8, 2016

Not only the connections with these libraries get broken but everything gets stuck if you load any of these connectors and you don't do manual page tracking calls.

@cfnelson
Copy link
Contributor

cfnelson commented Jun 22, 2016

@derouck There is an open issue that I believe explains the behaviour you noticed with Google Analytics and Hubspot over on segment.io's analytics.js repo ?

Currently if one integration fails no .ready() is fired. A substantial rewrite might be required on our end, but we are currently investigating.

We are working to resolve a few of the open bugs on the okgrow:analytics repo over the next week. Hopefully we will have a fix for you soon.

@derouck
Copy link
Author

derouck commented Jun 23, 2016

@cfnelson That's fine, I have a fairly simple workaround by changing trackPageWhenReady like this, so for me there's no rush.

var trackPageWhenReady = function () {
  var _args = arguments;
  analytics.ready(function () {analytics.page.apply(this, _args);});
};

var trackPage = function () {
  var _args = arguments;
  analytics.page.apply(this, _args);
};

With this approach, there could be some information missing, but the point is that a lot of the analytics systems want to know the first page when they are initialized. Then again they only say they are ready when they receive have tracked a page. Thus the only way forward is to start tracking pages. Otherwise, the Meteor package keeps waiting for Godot.

So possible solutions for this package are:

  • an option dontWaitForReady to start tracking immediately
  • have this behavior built-in when packages in the title are configured. In this case, there might remain a problem for those that add other integrations themselves, but they would only need to add the name of their integration to that list. This would probably be the easiest solution for users.

If the segment package would allow indicating that you don't need to wait for a ready for these integrations it could work as well, but considering the age of that bug it doesn't look like anyone will pick it up soon.

If you need some more information, let me know.

Good luck and thanks for the package!

@tsemana tsemana removed their assignment Jun 23, 2016
@cfnelson
Copy link
Contributor

cfnelson commented Jun 25, 2016

@derouck Thanks for your detailed response. Out of curosity are you using FlowRouter ?

I have worked on resolving a bug in our package where FlowRouter didn't log the intial page view. The fix is here #123 . I would be curious to know if this resolves your issue, though from reading your issue I suspect it is slightly different.

I like your 2nd solution. I will go check what libraries are using this assumesPageView and check these integrations behaviour. I am wanting to do a major refactor of this package which would hopefully enable the ability to users to use any of the segment.io's analytics-integrations. So your suggestion aligns nicely with this plan of mine. Hopefully I can incorporate them together.

I will keep you upto date on any progress I make.

@cfnelson
Copy link
Contributor

cfnelson commented Mar 3, 2017

Closing this issue as there has been no activity and believe it to be resolved. Please re-open if this bug comes back.

@cfnelson cfnelson closed this as completed Mar 3, 2017
@derouck
Copy link
Author

derouck commented Apr 5, 2017

The proposed solution is not a fix for the problem. The problem is that some (a lot) of the tracking services require data when they get initialised. The function that will track a page, will only do that once the ready event has been returned from the analytics.js package. This event will never come in this case as e.g. the Hubspot package will only initialise once there is data

const trackPageWhenReady = (...args) =>
analytics.ready(() => { . *** This will only happen ***
return analytics.page.apply(this, args) *** once this has been executed ***
});

So if you want to solve it you need to at least have one call of analytics.page.apply before having the others inside the ready check.

@craigdrayton
Copy link

I'm encountering the same issue.

If I have Google Analytics, Intercom and Mixpanel defined in settings.json it's working.
If I add Hubspot to settings.json also, no analytics are getting through to Mixpanel.

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

No branches or pull requests

7 participants