Feature #2959
openIntegrate Google Tag Manager Data Layer Push for Form Submission with GCLID Tracking
0%
Description
Objective
Implement Google Tag Manager (GTM) data layer push on successful form submission to support Google Ads Enhanced Conversions and track the associated GCLID with Salesforce lead data.
Requirements
1. GTM Data Layer Push
- Trigger a dataLayer.push() event when the form is successfully submitted.
- Push the required user details to the GTM data layer using the following event:
dataLayer.push({
event: 'ec_form_submit',
user_data: {
email: userEmail,
phone_number: userPhone
}
});
<script>
dataLayer.push({
'event':'ec_form_submit',
'user_data': {
"email": yourEmailVariable, /* Change yourEmailVariable to the actual Javascript variable name where you are storing the user’s email data. Do the same for the other variables below. Make sure the values aren't hashed. */
"phone_number": yourPhoneVariable, /* Phone Number must be collected in the E.164 format, which means it must be 11 to 15 digits including a plus sign (+) prefix and country code with no dashes, parentheses, or spaces. Example: ‘+11231234567’ */
}
})
</script>
Notes:
- Replace userEmail and userPhone with the actual JavaScript variables.
- Email should be passed in plain text (not hashed).
- Phone number must be in E.164 format, which means it must be 11 to 15 digits including a plus sign (+) prefix and country code with no dashes, parentheses, or spaces. (e.g., +11231234567).
2. GCLID Capture and Tracking
- Capture the gclid query parameter from the landing page URL (Google Ads click).
- Persist the GCLID during the user's journey (e.g., using a hidden form field, session/local storage, or cookie).
- Populate the form's hidden gclid field before submission.
- Include the captured GCLID in the data submitted to Salesforce.
- Ensure the GCLID is stored along with the corresponding lead/contact record in Salesforce.
3. Form Integration
- Add a hidden field to the form for storing the GCLID.
- Ensure the hidden field is automatically populated if a valid gclid is available.
- The GTM data layer push should execute only after a successful form submission.
Acceptance Criteria
- ec_form_submit event is pushed to the GTM data layer after successful form submission.
- User email is included in the user_data.email field.
- User phone number is included in the user_data.phone_number field in E.164 format.
- GCLID is captured from the landing page URL.
- GCLID is persisted until form submission.
- GCLID is submitted to Salesforce along with the lead data.
- GTM event can be verified using Google Tag Assistant or GTM Preview mode.
- Salesforce records contain the corresponding GCLID value when available.
Sample Script
<script>
dataLayer.push({
event: 'ec_form_submit',
user_data: {
email: yourEmailVariable,
phone_number: yourPhoneVariable
}
});
</script>
Reference
Google Ads Enhanced Conversions: https://support.google.com/google-ads/answer/7012522?sjid=14046845254776693930-NC
Reference implementation: https://www.theblossomnursery.com/book-a-tour?utm_source=pmax&utm_medium=paid&utm_campaign=burst&utm_bid=cpl&utm_language=en&utm_type=other&utm_medium=cpc&utm_source=google&utm_term=&utm_campaign=bo%2327044%7Cgooglepmax%7Cblossomnursery%7Cburst%7Cconversion%7Ccpl%7Cother%7Cen%7Cna&hsa_acc=5732118315&hsa_cam=23479304342&hsa_grp=&hsa_ad=&hsa_src=x&hsa_tgt=&hsa_kw=&hsa_mt=&hsa_net=adwords&hsa_ver=3&gad_source=1&gad_campaignid=23479306556&gbraid=0AAAABCgohdEn3h9uuuM_FYE5dBkF8KHbU&gclid=CjwKCAjwmdLSBhANEiwAkREMNwLaN8WT2d4VmNX8OxSdNPw8YvoxGq1-gu98-gzo3N4zKldsZcvjwxoCjRoQAvD_BwE
Testing:
Include the below console log and verify the output
code:
var _p = dataLayer.push;
dataLayer.push = function(){
var evt = arguments[0];
if (evt && evt.event === 'ec_form_submit') { console.log('EC PUSH SNAPSHOT:', JSON.stringify(evt)); }
return _p.apply(this, arguments);
};
output:
EC PUSH SNAPSHOT: {"event":"ec_form_submit","form_id":145224,"user_data":{"email":"manoj12vmit@gmail.com","phone_number":"+911236549870"}}
Updated by Manoj R about 1 month ago
- Description updated (diff)
- Status changed from New to Resolved