How to track goals manually (with javascript)

Manually executing goals is easy in SiteGainer. Just go to¬†goals and copy the ”pushGoal” (highlighted) library function for the goal you want to execute.

If you are not sure that the SiteGainer script has fully loaded when you want to push a goal, please add and if statement around the function that checks if SiteGainer has loaded before trying to run the function.


if(sitegainer) {
   sitegainer.pushGoal("{You goal id}");
} else {
  document.addEventListener("sitegainer-loaded", function(e) {
    sitegainer.pushGoal("{You goal id}");
  });
}

You can also use this code on links or any other element like this.

<a href="yourwebsite/example.html" onclick="sitegainer.pushGoal('4195');  //Change 4195 to your goal id "></a>

Also see:

How to use Standardised custom goals