如何生成唯一的url來跟蹤用戶簽名?

[英]How to generate unique urls to track user signups?


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.

然后你就可以知道是誰邀請了誰。有多少人(以及他們是誰)被一個給定的用戶邀請。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/04/30/72fe3111c69bbcf7971a4f8468f2745f.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com