I am using React-GA, and it works as expected, but I have a requirement to put user email in event tracking:
I see this in the example:
ReactGA.event({
category: 'Editing',
action: 'Deleted Component',
label: 'Game Widget'
});
I have a email of each user as a string. Where do I better put it in the request?
yes i am with #davids answer but i want to give more proper answer.
first you need to import react-ga module
import ReactGA from 'react-ga';
and than whenever you initialize google analytics you can set userId there
ReactGA.initialize('UA-000000-01', {
gaOptions: {
userId: xxx-xxx-xxx-xxx
}
});
Or if you want to set userId after user logs into your system, than you can do the following way
1. initialize google analytics without userId
ReactGA.initialize('UA-000000-01');
2. and just after login you can set userId
ReactGA.set({ userId: 123 });
ref: https://github.com/react-ga/react-ga#reactgasetfieldsobject
You should not use an email address as that is personally identifiable information and as such to track it in GA is against Google's terms and conditions.
User ID ("userId") should be setup in the "initialize" or "set" GA command, not in an event. User ID is scoped to the user, so it shouldn't ever change for a user. Also, you'll have convert email to an anonymous (non-PII) id before it's used as userId
ReactGA.initialize('UA-000000-01', {
debug: true,
titleCase: false,
gaOptions: {
userId: 123
}
});
User ID doc: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#userId
Related
I'm new in front-end development and learning Vue 3. I'm currently working on a user Login and Registration pages and I have a problem that I don't know how to solve properly.
The application has a Login page (with Email and Password fields) and a Registration page (with Email, Name, Password and Repeat password fields). Everywhere APIs are connected that check user data when clicking on the Submit button.
Now I have the following task: if the user enters an Email address that has already been registered before, then a pop-up window appears, which says: "Email is already in use. Sing Up to continue."
If the user clicks on Sing Up, then he should be routed to the Login page, in which the data that he just entered on the registration page will be automatically entered into the Email and Password fields.
For routing, I use Vue Router. I have read in the documentation that it is possible to pass props between components, however I am not sure if this is the safest and most correct method.
PS I can't use global state managers like Pinia or Vuex (the team I work for told me to not using them).
Thanks for your help and attention!
I tried using props method but I got problems during compilation
What kinda problem are you facing ? you need to insert the part of code at least or screenshot your problem.
If you want to pass data, you just add props in your route file, example :
{
path: "/example",
name: "example",
props: true,
}
And for sending a data, you need to pass data to params.
Example for option API:
this.$router.push('example', {
params: {email:email, pass:pass};
})
Example for composition API:
router.push({
name: 'example',
params: {email:email, pass:pass},
})
Dont forget to import router. Now you just add props variable:
props: ['email', 'pass']
//or composition API
const props = defineProps({
email: String, pass:String
})
const { email, pass } = toRefs(props)
I want to send welcome message to all admins of my user database. Is there any method in firebase so that I can get list of all users with their custom claim as admin set to be true.
admin.auth().getUsers([
{ uid: 'uid1' },
{ email: 'user2#example.com' },
{ phoneNumber: '+15555550003' },
{ providerId: 'google.com', providerUid: 'google_uid4' },
])
Would above method applicable? If yes, then what parameter should I pass?
There is no built-in way to query Firebase Auth users based on custom claims on a user. If you want to be able to query, you would need to mirror the information into another database (like Firestore) and query that.
Otherwise, you will need to fetch every user and filter the results, which presumably is not an ideal solution.
i'm using bottender & nodejs to create a bot messenger , but i got a problem when i try to retrieve the user id of a (admin or editor) in my page to know who send the response to a user in the page.
this is what i got :
{ sender: { id: '868761280555360' },
recipient: { id: '787381751469' },
timestamp: 1515780811774,
message:
{ is_echo: true,
mid: 'mid.$cAAUU4wBJk8VnHNjz_lg65PqOOZXZ',
seq: 361916,
text: 'hi' } }
sender : is the id of page and not the admin id for example.
recipient: user id who contact the page.
any one has a idea how i can get a sender id (admin or editor) of a page instead of page id with bottender.
The message was sent from the actual page. Even if there is an admin or editor who sent the message, he was using the page's identity, therefore is not possible to detect who actually sent the message.
You could tell your admins or editors to use a signature in the message. Split the message and get the admin's name.
You won't be able to get the sender behind the page, as facebook offcial docunment stated, here's a receiveing text message webhook event example:
{
"sender":{
"id":"<PSID>"
},
"recipient":{
"id":"<PAGE_ID>"
},
"timestamp":1458692752478,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"text":"hello, world!",
"quick_reply": {
"payload": "<DEVELOPER_DEFINED_PAYLOAD>"
}
}
}
ref:
https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/messages
https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-echoes
BTW, you can always check the rawEvent received when using bottender, with context.event.rawEvent.
It would be helpful sometimes.
I want to build an application where the users could login with Github (as of now, and probably Facebook, Google+ in the future).
I'm wondering how could I have initial properties when the user logs in first time, which would be modified in the future?
In my App component I have an onAuthStateChanged function which will push the users info into the database, but the issue is (obviously) that it will do this every time:
firebaseAuth.onAuthStateChanged((user) => {
if (user) {
this.setState({
user
});
usersRef.push({
id: user.uid,
displayName: user.displayName,
coins: 3000
});
} else {
this.setState({
user: undefined
});
}
});
Is there a way I could check if the user logged in before? Is there a better way to achieve what I want?
Perhaps you can use a Firebase Authentication Trigger as documented at https://firebase.google.com/docs/functions/auth-events.
You could set up a trigger that runs once on the Firebase servers just after a user is created; that trigger can update data in the database for the user, which could include defaulting certain values. Your React app would then be able to read that data when it needs it.
How can I use mixpanel in SPA? I want to track some events created by user.
When user opens page first time randomly generated ID is given to him. After signing in this action is executed.
mixpanel.alias(data.id);
mixpanel.track('Sign In', {
'Email': response.data.email
});
user.setCurrent(data);
In user.setCurrent function I do this:
mixpanel.identify(data.id);
But in my mixpanel account random ID still given to user? What should I do to prevent this?
Using mixpanel.identify doesn't actually change the ID Mixpanel uses:
On the signup confirmation page, you call mixpanel.alias("john#hotmail.com"). This doesn't actually change his ID - he is still being identified using the random ID we originally assigned him.
What you can do is to add the ID you use in your database to the Mixpanel Person, just like you do with the email at the moment. Then configure the Mixpanel UI to show that column in your reports.
mixpanel.track('Sign In', {
'Email': response.data.email,
'UserId': response.data.id
});