How to generate unique urls to track user signups?

2019-09-07 16:55发布

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?

This is for a Ruby on Rails app.

1条回答
贼婆χ
2楼-- · 2019-09-07 17:10

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.

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).

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.

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

查看更多
登录 后发表回答