Skip to main content
This is the complete, MongoDB-specific walkthrough for a credit referral programme: your referrers earn in-product credit, and TrackRev writes that credit straight into your users collection. Nothing here is Mongo-only except Half 1 — the API calls in Half 2 are the same for every database.
There are two halves that must agree. The API calls create the credit; the MongoDB connector delivers it into your collection. The value that ties them together is external_user_id.
Throughout, assume your users look like this:

Half 1 — Connect MongoDB (delivery, one time)

Open Configuration → Integrations → Credit fulfilment, choose MongoDB, and fill in:
Allow network access. TrackRev connects from serverless functions with no fixed IP. On MongoDB Atlas → Network Access → IP Access List, add 0.0.0.0/0 (or use PrivateLink / a static-egress proxy). Without it, saving connects to nothing and Test connection fails with a server selection timeout.
Then click Test connection — it should go healthy. (Test proves TrackRev can reach and read your database; it does not exercise the match column, so also confirm the first real referral lands.)

The one rule that makes it work

Whatever you send as external_user_id in the API must equal the value stored in your match_column. Pick one of these and stay consistent:

Match on _id

Set Match column to _id and enroll users with their Mongo _id string as external_user_id. TrackRev matches { _id: ObjectId(external_user_id) }.

Match on email

Set Match column to email and enroll users with their email as external_user_id. TrackRev matches { email: external_user_id }.
The connector matches an _id ObjectId, a string id, or a numeric id automatically — the credit field may be a number, or missing/null (it starts from 0). It just has to be the same identifier on both sides.

Half 2 — Wire the API in your app

1. Install the pixel

Tracks clicks and keeps the visitor id (_vid) alive across the visit.
Show referral_link to the user. (Or drop widget.js, which enrolls and renders a share card for you.)

3. Report the signup when a referred friend joins

The friend clicks the link, lands on your site with ?_vid=…, and you store it. When they create their account, call:
This is the call that actually creates the reward. _vid is the resolver, but you can also send ref_code (the link slug) or referrer_external_user_id instead.

What happens automatically

TrackRev creates the credit grant, then the fulfilment cron runs the MongoDB connector against your collection:
Alice’s credits goes 0 → 50. No delivery code on your side.

Verify end to end

1

Enroll user A

Call enroll for user A and copy the returned referral_link.
2

Click + sign up as user B

Open the link in a private window (?_vid=… appears in the URL), then sign up as B.
3

Report B's signup

Your backend calls report-signup with B’s id and the saved _vid.
4

Check MongoDB

A’s credits field has increased — proof the loop closed.
If credits appear in the dashboard but never reach the collection, it’s almost always the Atlas IP Access List (add 0.0.0.0/0) or a match_column that doesn’t match the external_user_id you enrolled with. See the connector’s last error on the Fulfilment page.
The credit rewards & fulfilment page covers the other connectors (Supabase, Postgres, Airtable, Webhook); the API steps above are identical for all of them.