Isolate JavaScript to specific page

You can add the following snippets of JavaScript to isolate specific portions of your JavaScript code on the Chargify pages of your choice.

Place custom JavaScript under Settings -> Public Page Default Settings -> Custom JavaScript.

You can add the following snippets of JavaScript to isolate specific portions of your JavaScript code on the Chargify pages of your choice.

Place custom JavaScript under Settings -> Public Page Default Settings -> Custom JavaScript.

Self-Service Page Only
if ($('#self-service-page').length === 1) {
//code here
}

// MODERN LAYOUT
Public Signup Page and Receipt Page Only
if ($('.public-signup-page').length !== 0) {
//code here
}

Receipt Page Only
if ($('.public-signup-page__success').length === 1) {
//code here
}

Public Signup Page Only
if ($('.public-signup-page__signup').length === 1) {
//code here
}

// CLASSIC LAYOUT
Public Signup Page and Receipt Page Only
if ($('#self-service-page').length === 0) {
//code here
}

Receipt Page Only
if ($('#hosted-payment-history').length !== 0) {
//code here
}

Public Signup Page and Self-Service Page Only
if ($('#hosted-payment-history').length === 0) {
//code here
}

Receipt Page and Self-Service Page Only
if ($('#total').length === 0) {
//code here
}

Public Signup Page Only
if ($('#total').length === 1) {
//code here
}

Examples

You may want to change your submit button text to say “Subscribe” on all of your public signup pages. You can use the following Javascript:

$( '#subscription_submit' ).val('Subscribe');

However, this will update the text of the submit button on Self-Service Pages too. Therefore, you can wrap your code inside the proper snippet from above.

Change button text on public signup page only

// MODERN LAYOUT
if ($('.public-signup-page__signup').length === 1) {
  $( '#subscription_submit' ).val('Subscribe');
}

// CLASSIC LAYOUT
if ($('#total').length === 1) {
  $( '#subscription_submit' ).val('Subscribe');
}

Change button text on self-service page only

if ($('#self-service-page').length === 1) {
$( '#subscription_submit' ).val('Update Info');
}

Here’s an example of the location of the Public Signup Page settings within the Chargify user interface.