Skip to main content
Solved

How do I add default event properties to a custom event?

  • December 22, 2023
  • 3 replies
  • 802 views

Phoenix

Hello, everyone.

I’m start to study Amplitude for the integration with my project.

I have trying to add default event properties such as PageDomain, PageTitle, PagePath, etc. to my custom event.

I have using default events such as PageViewed, Start Session, etc. in my project, but from my requirements I need to define custom event.

I’d like to use default properties such as PageDomain, PageTitle, PagePath, etc. in my custom event.

What’s suggestion to add these properties to my custom event ?

I hope to anyone help me for this.

Thank you.

Best answer by paladin8

Hi Phoenix, you’ll have to add those properties yourself to the event you want to instrument. Fortunately, that’s pretty straightforward. You can look at exactly how our SDK extracts these properties from the window `location` here and mimic it: https://github.com/amplitude/Amplitude-TypeScript/blob/c87f8bead0ff7330ff39c9c5a8698ddb65f5eb8e/packages/plugin-page-view-tracking-browser/src/page-view-tracking.ts#L26

View original
Did this topic help you find an answer to your question?

3 replies

paladin8
Team Member
Forum|alt.badge.img+4
  • Team Member
  • 26 replies
  • Answer
  • December 22, 2023

Hi Phoenix, you’ll have to add those properties yourself to the event you want to instrument. Fortunately, that’s pretty straightforward. You can look at exactly how our SDK extracts these properties from the window `location` here and mimic it: https://github.com/amplitude/Amplitude-TypeScript/blob/c87f8bead0ff7330ff39c9c5a8698ddb65f5eb8e/packages/plugin-page-view-tracking-browser/src/page-view-tracking.ts#L26


Phoenix
  • Author
  • New Member
  • 1 reply
  • December 25, 2023

Great !!!


That’s works for me.


hank you for your help.


  • New Member
  • 1 reply
  • July 13, 2024

With the Amplitude GTM template updates, is this still the case?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings