如何生成唯一的 url 来跟踪用户注册? [英] How to generate unique urls to track user signups?

查看:60
本文介绍了如何生成唯一的 url 来跟踪用户注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

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

This is for a Ruby on Rails app.

推荐答案

我不确定您的要求是什么.但是,如果您考虑这样的用例:用户 A 邀请 Not_yet_a_user_B.B 获得了一个唯一的注册网址.B点击并在站点中注册自己,站点在其数据库中记录了B是被A邀请的.

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.

有一个名为 Invitations 的模型(和一个基础表),带有字段(邀请代码:字符串,inviter_user_id:整数).一个用户可以拥有一对(一对一的映射......哦,你可以在用户表中保留邀请码)邀请.并且在 User 模型中有一个字段,名为 Invited_by_user_id:integer).

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

当 A 向 B 发送注册请求时,它看起来像:www.site.com/signup?invitation_code=ABC.因此,在您的注册操作中,您可以检查 Invitation_code 参数,然后对照 Invitations 表进行检查,以找出谁邀请了 B.然后将该用户 ID 记录在 B 的 Invited_by_user_id 中.

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.

这篇关于如何生成唯一的 url 来跟踪用户注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆