Callbacks
Callbacks allow you to "register" functions that will be executed when a specific event occurs.
You can define callbacks in the Configuration file. Callbacks is a property of the global variable window.RHConfig.
IMPORTANT
Callbacks must be defined BEFORE the Tracking Pixel.
Code
Callbacks
1
<script type="text/javascript">
2
window.RHConfig = {
3
callbacks: {
4
onLoad: function() {
5
// ... your logic ...
6
},
7
ready: function() {
8
// ... your logic ...
9
},
10
beforeSubmit: function(data) {
11
RH.form.data = {
12
name: "Mr "+ data.name,
13
14
extra_field: null,
15
extra_field_2: null
16
}
17
},
18
success: function(output) {
19
// ... your logic ...
20
21
},
22
afterSuccess: function(output) {
23
// ... your logic ...
24
},
25
error: function() {
26
// ... your logic ...
27
},
28
popupOpen: function() {
29
// ... your logic ...
30
},
31
popupClose: function() {
32
// ... your logic ...
33
},
34
subscriberNotFound: function() {
35
// ... your logic ...
36
},
37
emailNotValid: function(reason) {
38
// ... your logic ...
39
},
40
serverProblem: function(reason) {
41
// ... your logic ...
42
},
43
subscriberLoaded: function(response, data) {
44
// ... your logic ...
45
}
46
}
47
}
48
</script>
Copied!
Callback
Description
onLoad
It's triggered before everything else.
ready
It's triggered when the Tracking Code is initialized, the widgets have been generated and all libraries have been loaded.
beforeSubmit
It's triggered right before the sign-up form is submitted. Useful to change the data before is sent. It receives an object that contains the data from the form (name, email, etc). To change the data, change the properties of the RH.form.data object.
success
It's triggered after the sign-up form has been successfully submitted. It receives an object that contains the response of the submission. Initializing this callback will prevent the sharing screen from appearing.
afterSuccess
It's triggered after the form has been successfully submitted. It receives an object that contains the response of the submission. Initializing this callback will NOT prevent the sharing screen from appearing.
error
It's triggered if there was an error with the form submission.
popupOpen
It's triggered when the popup is opened.
popupClose
It's triggered when the popup is closed.
subscriberNotFound
It's triggered when an email that doesn't exist is used to check the status
subscriberLoaded
It's triggered when a subscriber is identified.
emailNotValid
It's triggered when the email entered is not valid. It receives one parameter: reason, which contains the reason why ReferralHero thinks that email is not valid.
serverProblem
It's triggered when the server returns a 500 or 4XX error.
Last modified 1yr ago
Copy link