Integrate GA Connector with custom forms

The instructions below apply to Cookie-Based integration.

If you are using API-Based integration, simply add the GA Connector script to your main website. No additional steps are required.

Not sure which instructions to follow? Start here: How to Check Which GA Connector Integration Type You’re Using.

Prerequisites

This instruction assumes that you have already installed either GA Connector WordPress plugin, or GA Connector script:

HTML
<script data-cfasync="false" type="text/javascript" src="https://tracker.gaconnector.com/gaconnector.js"></script>
<script>
function setGaconnectorHiddenFields() {
    var gaFields = gaconnector.getCookieValues();
    for (var fieldName in gaFields) {
        var selectors = 'form input[name="' + fieldName + '"], form input#' + fieldName + ', form input#field_' + fieldName + ', form input[name="' + fieldName.toLowerCase() + '"], form input#' + fieldName.toLowerCase() + ', form input#field_' + fieldName.toLowerCase() + ', input[value="gaconnector_' + fieldName + '"],';
        selectors += 'form textarea[name="'+fieldName+'"], form textarea#'+fieldName+', form textarea#field_'+fieldName + ', form textarea[name="'+fieldName.toLowerCase()+'"], form textarea#'+fieldName.toLowerCase()+', form textarea#field_'+fieldName.toLowerCase()+', form textarea.'+fieldName+', form textarea[name="param['+fieldName+']"]'+", form textarea[id^='field_"+fieldName+"']";
        var inputs = document.querySelectorAll(selectors);
        if (inputs === null) {
            continue;
        } else if (typeof inputs.length === 'undefined') {
            inputs.value = gaFields[fieldName];
        } else {
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].value = gaFields[fieldName];
            }
        }
    }
}

gaconnector.setCallback(setGaconnectorHiddenFields);
setInterval(setGaconnectorHiddenFields, 1000);
</script>

Now that you've installed our script, you need to make modification to your forms. There are two methods of integrating your forms with GA Connector:

Integration Method #1

Step 1: Add hidden fields with specific names to your forms

GA Connector script will automatically fill them out with users' source, medium, keywords, location etc. Names of these fields help GA Connector script understand where to put the values.

Here is the list of fields you need to add to your forms:

HTML
<input type="hidden" id="fc_campaign">
<input type="hidden" id="fc_channel">
<input type="hidden" id="fc_content">
<input type="hidden" id="fc_landing">
<input type="hidden" id="fc_medium">
<input type="hidden" id="fc_referrer">
<input type="hidden" id="fc_source">
<input type="hidden" id="fc_term">
<input type="hidden" id="lc_campaign">
<input type="hidden" id="lc_channel">
<input type="hidden" id="lc_content">
<input type="hidden" id="lc_landing">
<input type="hidden" id="lc_medium">
<input type="hidden" id="lc_referrer">
<input type="hidden" id="lc_source">
<input type="hidden" id="lc_term">
<input type="hidden" id="OS">
<input type="hidden" id="GA_Client_ID">
<input type="hidden" id="gclid">
<input type="hidden" id="all_traffic_sources">
<input type="hidden" id="browser">
<input type="hidden" id="city">
<input type="hidden" id="country">
<input type="hidden" id="device">
<input type="hidden" id="page_visits">
<input type="hidden" id="pages_visited_list">
<input type="hidden" id="region">
<input type="hidden" id="time_zone">
<input type="hidden" id="time_passed">
<input type="hidden" id="latitude">
<input type="hidden" id="longitude">

Each hidden field needs to have a distinct attribute that would allow the script to understand which field is which. In the example above, it's id.

But it can also be a name:

HTML
<input type="hidden" name="lc_source">

Or class:

HTML
<input type="hidden" class="lc_source">

Note: If your form doesn't allow you to modify its ID, name, or class attribute, you can integrate your form with GA Connector using default values instead. Read More.

Step 2: Connect your new hidden fields to CRM fields

Now that you've added hidden fields to your forms, GA Connector script will automatically fill them out with tracking data.

The final step is to connect these hidden fields with your CRM fields. You need to modify the code that sends data to your CRM, and make it so that it also sends these new hidden fields (alongside your users' email, name etc).

Integration Method #2

You can also integrate your forms without adding hidden fields, if your forms allow you to edit the code that submits them.

In that case, you can do it on the server side, using PHP, C#, Python or another language you use on the server. You can write some code that appends cookie values from screenshot 1 to the form submission, before sending it to the CRM.

Something like this:

$submission = $_POST;
$submission['Last Click Source'] = $_COOKIE['gaconnector_lc_source'];
$submission['Last Click Medium'] = $_COOKIE['gaconnector_lc_medium'];
//...
send_to_crm($submission);

More than just UTM parameters

GA Connector adds UTM information, geolocation, referral information to your custom forms.

See below for all the information that you can add to your leads to help you find out which of your marketing activities drive sales.

Label Input ID Label Input ID
All Traffic Sources gaconnector_all_traffic_sources Last Click Campaign gaconnector_lc_campaign
Browser gaconnector_browser Last Click Channel gaconnector_lc_channel
City (from IP address) gaconnector_city Last Click Content gaconnector_lc_content
Country (from IP address) gaconnector_country Last Click Landing Page gaconnector_lc_landing
First Click Campaign gaconnector_fc_campaign Last Click Medium gaconnector_lc_medium
First Click Channel gaconnector_fc_channel Last Click Referrer gaconnector_lc_referrer
First Click Content gaconnector_fc_content Last Click Source gaconnector_lc_source
First Click Landing Page gaconnector_fc_landing Last Click Term gaconnector_lc_term
First Click Medium gaconnector_fc_medium Last Click Timestamp gaconnector_lc_timestamp
First Click Referrer gaconnector_fc_referrer Longitude gaconnector_longitude
First Click Source gaconnector_fc_source Latitude gaconnector_latitude
First Click Term gaconnector_fc_term Number of Website Visits gaconnector_page_visits
First Click Timestamp gaconnector_fc_timestamp Operating System gaconnector_OS
Google Analytics CID gaconnector_GA_Client_ID Device gaconnector_device
Google Analytics Measurement ID gaconnector_GA_Measurement_ID Region gaconnector_region
Google Analytics Session ID gaconnector_GA_Session_ID Pages Visited gaconnector_pages_visited_list
Google Click Identifier gaconnector_gclid Time Spent on Website gaconnector_time_passed
IP Address gaconnector_ip_address Time Zone gaconnector_time_zone