Custom Prebuilt Goals

Introduction

It is possible within Convert to create a custom goal and make it available to you and your collaborators for use in your experiments.

In this article, we will create a goal that is triggered when somebody scrolls to the bottom of the page.

Below is the process of how to do it:

Create a JavaScript Goal

First, create a JavaScript Goal. Name it "Scroll to Bottom” and save it.

mceclip0.png

Re-edit the goal, and you will find the code to trigger it has been created within the goal. For example:
mceclip0.png

Sample JavaScript Code for an Action

Following is the code that issues an alert when the user scrolls down a web page.


var scrollgoal_triggered;
window.onscroll = function(ev) {
   if ((window.innerHeight + window.scrollY) >= document.body).offsetHeight)  {
       alert("you're at the bottom of the page");
     }
};

Integrate JavaScript Code

Let's integrate the JavaScript goal code into our scroll to bottom alert code.


var scrollgoal_triggered;
window.onscroll = function(ev) {
  if ((window.innerHeight + window.scrollY) >= document.body).offsetHeight) && (scrollgoal_triggered = false) {
        window._conv_q = window._conv_q || [];
       _conv_q.push(["triggerConversion","100122012"]);
       scrollgoal_triggered = true;
   }
};

Add Code in Global Project/Global Experience JavaScript

Include code on your website pages by adding it to the "Global Project JavaScript" area in your "Project Configuration" (you can also use the Global Experience JavaScript section accessible from the Visual Editor):

mceclip2.png

Your "Scroll to Bottom" goal will then be available for all your experiments.

Important

keywords: JavaScript goal custom

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments