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

Allow for better page tracking in segment #75

Closed
Carl-Meyer opened this issue Aug 11, 2020 · 4 comments
Closed

Allow for better page tracking in segment #75

Carl-Meyer opened this issue Aug 11, 2020 · 4 comments

Comments

@Carl-Meyer
Copy link

Hi there

I was using angulartics2 as an analytics library before switching to analytics. We are sending our analytics to segement.
I hoping to ask if there is a way to send through page data in a better format similarly to how it was when using angulartics2?

Here is what I mean:
Angulartics2
Screenshot 2020-08-11 at 10 02 46

analytics
Screenshot 2020-08-11 at 10 03 01

I like the fact that analytics sends the height and width as well. I have added the name field to the page track call myself which is working fine but when viewing it in the segment debugger it shows as /recruiting/ instead of Job Postings

Thanks for the hard work :)

@DavidWells
Copy link
Owner

DavidWells commented Aug 15, 2020

You can customize the payload of page views, identity calls, and tracking events with custom plugins

For example, if you want all pageView calls to have something specific or keys removed you can use a plugin. Hook into the pageStart lifecycle event.

import Analytics from 'analytics'
import segmentPlugin from '@analytics/segment'

function myCustomPageDataPlugin(userConfig = {}) {
  return {
    name: 'my-custom-page-plugin',
    config: Object.assign({}, userConfig),
    pageStart: ({ payload }) => {
      // Alter payload before it reached .page calls
      return Object.assign({}, payload, {
        addThis: 'hello',
        addThat: 'goodbye'
      })
    }
  }
}

/* initialize analytics and load plugins */
const analytics = Analytics({
  debug: true,
  app: 'yolo',
  plugins: [
    myCustomPageDataPlugin(),
    segmentPlugin({
      writeKey: 'xyz'
    })
  ]
})

analytics.page()

@Carl-Meyer
Copy link
Author

Hi @DavidWells thank you for taking the time to reply. I will investigate to see if this will achieve the desired effect. I think I had issues altering the page call to be able to have Page(name, pageData) go through since the Page interface only allows for calling Page (page Data) but let me have a look and see what I can accomplish. Thanks again 👍

@DavidWells
Copy link
Owner

Hwy @Carl-Meyer any updates here?

@Carl-Meyer
Copy link
Author

Hi @DavidWells seems like not having the page name param in the sentry preview isn't an issue for us so I didn't end up implementing your solution. Sorry, but thank you for the support.

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

2 participants