# Tracking referrals? Encouraging users to invite others?

**URL:** https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040
**Category:** Community Building
**Created:** [Novembre 29, 2017, 8:54 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040 "2017-11-29T20:54:51Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![shaundefense](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaundefense/32/119563_2.png) [@shaundefense](https://meta.discourse.org/u/shaundefense)
#### Post date: [Novembre 29, 2017, 8:54 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/1 "2017-11-29T20:54:51Z")

</div>

I’m looking for ways to grow my site. We are close to 1000 members but we just hit a slump in growth.

We plan on doing a contest of some type but we want to make sure the contest encourages further growth. We thought about doing a contest: Whoever invites the most active users in 30 days wins.

This could be effective but the problem is I don’t see any admin overview of signups via invite or sitewide user activity, so it would be difficult to track.

**Does anyone know of a way we can track invites and user activity sitewide?**

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [Novembre 30, 2017, 1:15 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/2 "2017-11-30T13:15:58Z")

</div>

This is something for the [Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566) plugin, it allows you to run custom SQL queries against the Discourse database.

If you’re somewhat versed in SQL, using [Data Explorer](https://meta.discourse.org/t/32566?silent=true) is pretty easy since it has included help to show you the database scheme; otherwise, I’m sure you’ll get some help here if you describe what you want, exactly 🙂

---

<div class="post-metadata">

### Author: ![SidV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sidv/32/119460_2.png) [@SidV](https://meta.discourse.org/u/SidV)
#### Post date: [Novembre 30, 2017, 2:34 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/3 "2017-11-30T14:34:46Z")

</div>

As @fefrei said, you can use [Data Explorer](https://meta.discourse.org/t/32566?silent=true) with a query like this:

```sql
-- [params]
-- int :limit

select user_id, 
    invited_by_id
from invites
where created_at > CURRENT_TIMESTAMP - INTERVAL '30 days'
and user_id > 1
limit :limit

```

And modify that query with more complex query if you want.  
See this **[queries’s directory](https://github.com/SidVal/discourse-data-explorer/blob/queries/querys.md)** that you can use

Good luck !

Ps, updated: I added **[tracking-referrals.sql](https://github.com/SidVal/discourse-data-explorer/blob/queries/queries/tracking-referrals.sql)** to the list 😉

---

<div class="post-metadata">

### Author: ![shaundefense](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shaundefense/32/119563_2.png) [@shaundefense](https://meta.discourse.org/u/shaundefense)
#### Post date: [Décembre 5, 2017, 7:06 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/4 "2017-12-05T19:06:24Z")

</div>

Thanks for the help!

---

<div class="post-metadata">

### Author: ![Henry\_Cooper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/henry_cooper/32/97503_2.png) [@Henry\_Cooper](https://meta.discourse.org/u/Henry_Cooper)
#### Post date: [Octobre 30, 2018, 7:59 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/5 "2018-10-30T19:59:23Z")

</div>

> [@SidV](#):
>
> Ps, updated: I added **[tracking-referrals.sql](https://github.com/SidVal/discourse-data-explorer/blob/queries/queries/tracking-referrals.sql)** to the list 😉

I tried running this and got a syntax error “at or around line 25”

---

<div class="post-metadata">

### Author: ![SidV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sidv/32/119460_2.png) [@SidV](https://meta.discourse.org/u/SidV)
#### Post date: [Octobre 31, 2018, 12:54 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/6 "2018-10-31T12:54:55Z")

</div>

Henry, on that link there are two queries. Which version are you trying ?  
I tested the both now, and works fine. 🤔

---

<div class="post-metadata">

### Author: ![Henry\_Cooper](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/henry_cooper/32/97503_2.png) [@Henry\_Cooper](https://meta.discourse.org/u/Henry_Cooper)
#### Post date: [Novembre 9, 2018, 6:23 UTC](https://meta.discourse.org/t/tracking-referrals-encouraging-users-to-invite-others/75040/7 "2018-11-09T18:23:29Z")

</div>

Oops. Didn’t notice there was two. I ended up copy pasting both thinking it was one.

Problem solved 🙂
