Custom JavaScript

Raisely's Custom JavaScript integration lets you write your own JavaScript code to fire on different events across Raisely. As Raisely websites are React applications, code loaded in the `<head>` of your website won't run on every page.

Custom Javascript allows you to fire your own JavaScript code, like custom tracking scripts, front-end/client-side integrations, or other tweaks to the user experience of your website.

📝 Custom JavaScript is not designed as a way to add custom functionality to your website. It's really designed with tracking and analytics in mind. If you want to add custom functionality, you should use a custom component.

⚠️  Custom JavaScript is added at your own risk. We can't help with custom code you add to this section of your website.

Adding your JavaScript

To add custom javascript, log into your Raisely admin panel and go into the campaign you're editing. In the left sidebar, click Settings then Apps & Integrations. You'll find "Custom Javascript" towards the bottom of the list.

Subscribing to Events

Let's say we want to run a tracking script on every page in my Raisely campaign. By default this will only run on the page I land on, so I want to make sure it tracks every other page I visit too.

To do this, we use the subscribe method that will be passed into your script. Here's an example:

subscribe('page.viewed', function(page) {

subscribe accepts the event as the first argument, and a function to run on that event as the second. That function always has one argument, which will be a JSON object of relevant information.

I can add multiple subscriptions to my JavaScript, like so:

subscribe('page.viewed', function(data) {

subscribe('donation.success', function(data) {

The easiest way to see what's available in data is just to use a console.log to inspect the payload, as it does vary between events. These are the same subscription events we use to run built-in integrations like Google Analytics, so you will have plenty of data to play with.

List of events

page.viewed On each page view/load
user.signup On a new registration
user.login On a successful account login
profile.created When a team is created after signup, or also fired on a complete signup
profile.updated When profile (team or individual) is updated
post.created New blog post created
donation.stage Fired on each stage during the donation form, including the first
donation.success On a new successful donation
subscription.success On a new successful regular donation
user.authenticated We've been able to log a user in. This is different to user.login as it's fired on load if the user is already authenticated.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us