openpixel icon indicating copy to clipboard operation
openpixel copied to clipboard

Classify events separatly

Open hashiranwaar opened this issue 3 years ago • 4 comments

Everything fine, Thanks for Pixel.

One thing i need to ask, Is there any easy way to make pixel work like opix.track('event', 'reservation', {'key' : 'value'}) to track the events

and opix.user.setEmail('email', '[email protected]') to set or update user's profile data.

Means, If we have that sort of function it will be easy to call API on basis of function called.

Thanks

hashiranwaar avatar Nov 11 '20 10:11 hashiranwaar

Hi there 👋 what are you looking to accomplish here? Are you trying to set default data that will be sent on every event trigger or something? Some more detail would be great 👍

stuyam avatar Nov 12 '20 02:11 stuyam

@stuyam , the Pixel send all event generally as same ...like if user is passing login event or register event or product viewed event...all events are coming at same place.

What i am looking for is,

if we can make classes or methods in pixel for different purposes.

I mean , if we want to track user events ...we can use a class like opix.track('event_name', {EVENT_DATA}) so this function will send event data to DATA INSERT API https://api.example.com/events

And for user related events e.g if user login, register or update his email/mobile number , we can call class like opix.user.setAttributes('Email', '[email protected]') , OR opix.user.login('USER_ID_HERE') so this method will directly send data to user profile update API like https://api.example.com/users

Hope you got my point....If need more detail... i will explain..

Thanks @stuyam 👍

hashiranwaar avatar Nov 12 '20 07:11 hashiranwaar

Ok so what it sounds like you want is the ability to send event data to different urls rather than only supporting one? So being able to send some events to https://api.example.com/events and some to https://api.example.com/users?

It seems like you are trying to use open pixel like ajax to send updates to your backend? Im not sure open pixel is an ideal candidate for something like that. Why couldn't you use ajax or fetch for making updates to a user in this case?

stuyam avatar Nov 12 '20 21:11 stuyam

I made a switch Case with event name so i can change API endpoint according to event type .. :)

switch (this.event){
  case 'login':
     this.api_url = 'https://api.example.com/user_login'
     break;
  .
  .
  .
  default:
    this.api_url = 'https://api.example.com/postEvent'
}

hashiranwaar avatar Nov 14 '20 06:11 hashiranwaar