Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

[draft] Track page load #558

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

[draft] Track page load #558

wants to merge 2 commits into from

Conversation

buren
Copy link
Member

@buren buren commented Nov 23, 2017

⚠️ Not at all ready for merge!

I'd like to be able send each page view to the API, so we can track users path through the system (especially useful for checking how users behave before they apply for a job).

The API uses a plugin for backend events called ahoy and there is a simple client side JavaScript implementation ahoy.js.
Perhaps the simplest would be to include ahoy.js and then fire most of the events manually, rather than relying on its default behaviour (which wont work, since we have a SPA).

@buren buren temporarily deployed to just-match-web-sandbox-pr-558 November 23, 2017 11:20 Inactive
@justarrived justarrived deleted a comment from burenbot Nov 23, 2017
@justarrived justarrived deleted a comment from burenbot Nov 23, 2017
@@ -55,9 +55,22 @@ export abstract class PageComponent extends BaseComponent implements OnInit, OnD

this.pageOptionsService.setTransparentNavbarWhenTopScrolled(this.transparentNavbarWhenTopScrolled);

this.sendAnalyticsEvent();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the best place to put this code @bex1 any other ideas or is this OK?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the code should be placed in the navigation.service.ts instead.

You can use the router.events subscription in the initService method.

this.router.events.subscribe(event => {
      if (event instanceof NavigationStart) {
        console.log('Starting navigation to ' + event.url)
      }

      if (event instanceof NavigationEnd) {
        this.currentUrl = this.router.url;
        if (isPlatformBrowser(this.platformId)) {
          window.scrollTo(0, 0);
        }
        console.log('Navigation ended at ' + this.currentUrl);
      }

      if (event instanceof NavigationCancel) {
        console.log('NavigationCancel');
      }

      if (event instanceof NavigationError) {
        console.log('NavigationError', event);
      }

      if (event instanceof RoutesRecognized) {
        console.log('RoutesRecognized');
      }
    });

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants