Installing sign up snippet (into code) to send us referral data.

By installing a line of code in your sign up form, we are able to track who signed up via which affiliate. See here how to install this code (with examples).

The Reditus Sign-up Snippet is a single line of code that should be inserted after a successful sign-up submission. This snippet sends Reditus the email of the person who signed up. 

Make sure to replace email@example.com with the actual email address (the attribute) of the user who is signing up.

Before installing the snippet, ensure that you have already added the tracking script to your page.

How Does the Snippet Work?

When a visitor arrives through a partner referral, a cookie will track their activity. The next crucial step is for the visitor to sign up. When they do, Reditus needs their email address to continue tracking them throughout their journey.

This email will appear:

  • In the partner's dashboard
  • In your dashboard
  • We’ll also track this email in your Stripe account for proper commission tracking.

For a step-by-step guide, check out this video tutorial:
Installing the Sign-up Snippet

Where to Find the Snippet?

You can find the Snippet in your Reditus settings. To avoid any mistakes, use the copy button to copy the code snippet directly without any typos.

How to Add the Snippet to Your Sign-up Form

Ruby on Rails Integration

If you're using Ruby on Rails, you'll need to mark new referrals when a user successfully signs up. Add the following code to your application to track user registrations using the Devise gem.

1. Controller: In your app/controllers/users/registrations_controller.rb, you’ll track successful user sign-ups like this:
class RegistrationsController < Devise::RegistrationsController
def create
#...
resource.save
if resource.persisted?
# Account created
session[:reditus_referral] = sign_up_params[:email]
else
# Authentication failed
# ...
end
end
end

Here, we store the email of the newly created user in session[:reditus_referral].

2. View: In your app/views/layouts/application.html.erb, add the following code to call the tracking method after the registration is complete:
ruby
<% if session[:reditus_referral].present? %>
<script>
window.gr("track", "conversion", { email: "<%= session[:reditus_referral] %>" });
</script>
<% end %>

React JS Integration

In a React application, you'll need to call the Reditus conversion event in the callback of your sign-up success handler.

handleSignupSubmit(values) {
const { signUp } = this.props;
signUp({ ...values })
.then(() => {
console.log('Account created successfully.');
if (typeof window.gr === 'function') {
console.log('✅ gr function is defined');
window.gr("track", "conversion", { email: "actual@email.com" });
} else {
console.log('⛔️ gr function is NOT defined');
}
})
.catch((err) => {
console.log('Something went wrong. Please try again later!');
});
}

JavaScript Integration

For standard JavaScript, simply include the snippet in your success handler when the user signs up:

if (typeof window.gr === 'function') {
window.gr("track", "conversion", { email: "actual@email.com" });
} else {
console.error('Tracking Script not running, check why.');
}

 

By following these steps, you'll ensure Reditus can track sign-ups and referral conversions seamlessly, allowing for more effective management of your affiliate program.