如何生成唯一的url来跟踪用户签名?

时间:2021-09-07 16:29:17

I want to generate a unique url for each user that signs up for my app. The urls should all lead to the same sign up page but each one will be associated with the one user that received it when signing up. Then every time a new user signs up through the unique url, the number of signups associated with that url will increment by one. Therefore, I can track the number of signups generated by each user. How do I build such a system?

我想为注册我的应用的每个用户生成一个唯一的url。这些url应该都指向同一个注册页面,但每个url都与注册时接收到它的一个用户相关联。然后,每当新用户通过唯一url注册时,与该url关联的签名数量将增加1。因此,我可以跟踪每个用户生成的签名数量。我如何构建这样一个系统?

This is for a Ruby on Rails app.

这是一个Ruby on Rails应用程序。

1 个解决方案

#1


1  

i am not exactly sure what your requirement is. But if you thinking of a use case like: User A invites Not_yet_a_user_B. And B gets a unique signup url. B clicks that and register him self in the site and the site records in its db that B was invited by A.

我不太清楚你的要求是什么。但是如果您考虑一个用例:User a邀请Not_yet_a_user_B。B得到一个唯一的注册url。B点击它,在网站上注册自己,网站在db上记录B被A邀请。

You could implement something like this.

你可以实现类似的东西。

Have a model (and a underlying table) called Invitations with fields (invitation code:string, inviter_user_id:integer). A User can have one (one to one mapping.. oh you can just keep the invitation code in the User table) Invitations. And in the User model have a field called invited_by_user_id:integer).

有一个名为invite的模型(和一个底层表)和字段(邀请代码:string, inviter_user_id:integer)。用户可以有一个(一对一映射)。哦,你可以把邀请码放在用户表中)邀请。在用户模型中有一个名为invited_by_user_id:integer的字段。

When A send a sign up request to B, it will look like: www.site.com/signup?invitation_code=ABC. So in your sign up action you can check for the invitation_code parameter and then check it against the Invitations table to find out who invited B. Then record that User ID in B's invited_by_user_id.

当A向B发送一个注册请求时,它将看起来像:www.site.com/signup?invitation_code=ABC。所以在您的注册操作中,您可以检查invitation_code参数,然后对照invite表检查谁邀请了B,然后在B的invited_by_user_id中记录该用户ID。

Then you can tell who was invited by who. And how many people (and who they are) were invited by a given user.

然后你就可以知道是谁邀请了谁。有多少人(以及他们是谁)被一个给定的用户邀请。

#1


1  

i am not exactly sure what your requirement is. But if you thinking of a use case like: User A invites Not_yet_a_user_B. And B gets a unique signup url. B clicks that and register him self in the site and the site records in its db that B was invited by A.

我不太清楚你的要求是什么。但是如果您考虑一个用例:User a邀请Not_yet_a_user_B。B得到一个唯一的注册url。B点击它,在网站上注册自己,网站在db上记录B被A邀请。

You could implement something like this.

你可以实现类似的东西。

Have a model (and a underlying table) called Invitations with fields (invitation code:string, inviter_user_id:integer). A User can have one (one to one mapping.. oh you can just keep the invitation code in the User table) Invitations. And in the User model have a field called invited_by_user_id:integer).

有一个名为invite的模型(和一个底层表)和字段(邀请代码:string, inviter_user_id:integer)。用户可以有一个(一对一映射)。哦,你可以把邀请码放在用户表中)邀请。在用户模型中有一个名为invited_by_user_id:integer的字段。

When A send a sign up request to B, it will look like: www.site.com/signup?invitation_code=ABC. So in your sign up action you can check for the invitation_code parameter and then check it against the Invitations table to find out who invited B. Then record that User ID in B's invited_by_user_id.

当A向B发送一个注册请求时,它将看起来像:www.site.com/signup?invitation_code=ABC。所以在您的注册操作中,您可以检查invitation_code参数,然后对照invite表检查谁邀请了B,然后在B的invited_by_user_id中记录该用户ID。

Then you can tell who was invited by who. And how many people (and who they are) were invited by a given user.

然后你就可以知道是谁邀请了谁。有多少人(以及他们是谁)被一个给定的用户邀请。