Google Analytics event tracking with custom code


Our direct Google Analytics integration uses the analytics.js script that Google provides in order to track default page views as seen here: When you need more advanced metrics tracked with Google Analytics, you will have to add their tracking script following the instructions below, after customizing it to fit your particular situation. Please refer to this guide for event tracking with GA4:

Google Analytics 4 is the next-generation measurement solution, and have replaced Universal Analytics. On July 1, 2023, standard Universal Analytics properties stopped processing new hits. Analytics 360 will stop processing hits on 1 July 2024.

The following guide helps you implement custom button click or by form submission events for Google Analytics, using gtag.js javascript version.

With this option, you will not use our direct integration at all.

Conversions will be triggered either by button clicks/form submissions on the main page or by visits to a thank you page (used as a conversion page).

1. Conversions triggered by button clicks

You can easily add Google Analytics events that fire upon button clicks using the code snippet below. Paste the code into Settings - Javascript - Body:

For any Google Analytics event, you will need to customize the event parameters. You will need to replace the square brackets with your event fields. Please consult Google’s documentation for more information about how to configure your Google Analytics events:

Here is how you can find the button element ID number:


If you want to track multiple buttons, you will have to add the code again for each button. Don’t forget to customize all the individual code snippets to have the correct element ID number and event parameters for each separate button.

2. Conversions triggered by form submissions

While you can check the form submissions on our built-in Analytics dashboard (link to our article), you can also set up a Google Analytics event to track them.

Note that we offer two different code snippets for when you want to fire the same Google Analytics event for all your page forms, and also a different code snippet for when you want to fire a different Google Analytics event for each form on your page.

If you have one form on the page, you need to paste the following snippet into Settings - Javascript - Body:

Just like with event fired on button clicks, be sure to customize the event parameters as per Google’s documentation:

If you have multiple forms on the same page, please use the snippet below. This needs to be pasted into Settings - Javascript - Body:

For this second code snippet, you will need to edit the "wid" value, which is only the digit part of the element ID. For #element-659, the "wid" value is "659".

NOTE: The "instapageFormSubmitSuccess" function can only be present on the page once, regardless of how many forms you have or how many actions you want to trigger after form submission. In case you have multiple snippets that need to fire after form submission, you must add all of them under the same Form Submit Callback function. If the snippets are not added under the same Form Submit Callback script, only the last function in the source code will be triggered.

3. Conversions triggered on the thank you page

You can also track conversions with a thank you page. First, create and publish a thank you page, and then set your main landing page to redirect to the thank you page after form submission as shown here: In this case, both pages should have the Google Analytics ID added in Settings - Analytics, and the thank you page should contain this code snippet as well, in Settings - JavaScript - Head or Body:

Note: Google Analytics needs 24 hours to process the data received.

Note: We only offer the ability to add custom code. We do not provide custom code assistance through the support team.