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

An option to check if the pure pathname is different before pushing a new page track event #401

Open
1 of 3 tasks
unsignedmind opened this issue Nov 20, 2020 · 0 comments

Comments

@unsignedmind
Copy link

unsignedmind commented Nov 20, 2020

For support questions, please consider using Gitter - Chat

I'm submitting a ...

  • bug report

  • feature request

  • question about the decisions made in the repository

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

  • What is the expected behavior?
    Implement an option to check if the pure pathname is different before pushing a new page track event.

public startTracking() {

    let prev = '';

    this.angulartics2.pageTrack.pipe(this.angulartics2.filterDeveloperMode()).subscribe((x) => {
      const pathPrev = prev.split('?')[0];
      const pathNext = x.path.split('?')[0];
      const changed = pathPrev !== pathNext;
      // console.log('dataLayer', '\nPAGETRACK:', x, '\nPREV: ', { prev, rawPrev: pathPrev }, '\nNEXT: ', { next: x.path, rawNext: pathNext }, dataLayer);
      prev = x.path;
      return changed ? this.pageTrack(x.path) : null;
    });
  }
  • What is the motivation / use case for changing the behavior?
    We are building a webshop and on our product detail page there is a functionality that adds meta infos to the query params. When doing so the url changes and a page track event get's fired. So the same page get's tracked twice.

  • Environment:
    angular 10 / angulartics 10

ng version: 6.13.4

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

No branches or pull requests

1 participant