The Easy Way to Track and Tag User Behavior
The best way to set up tracking in Google Tag Manager (GTM) is to follow this structured approach:
- Inspect the Data Layer Variables – Identify where the required data is stored.
- Create Necessary Variables – Define variables in GTM to capture the data.
- Create Triggers – Define the conditions under which the tags should fire.
- Create Tags – Set up Google Analytics and Google Ads tags to send event data.
This structured approach ensures accurate tracking while making it easier to troubleshoot.
Step 1: Configure Calendly Settings
Before setting up tracking, modify your Calendly settings to pass data properly:
- Open Calendly and navigate to the Event Type Settings.
- Scroll to the Confirmation Page section.
- Enable Redirect URL and enter the URL where users should land after booking.
- Check the box for “Pass event details to your redirected page”.
✅ This ensures that booking details (e.g., email, phone number) are included in the URL.
Once this is enabled, Calendly will pass user details via URL parameters (e.g., ?invitee_email=example@gmail.com).

Step 2: Add the Calendly Listener
We need to add a Calendly listener in GTM to capture user interactions.
- Go to GTM → Click Tags.
- Click New → Select Custom HTML.
- Name the tag cHTML – Calendly Listener.
Add the following code in the HTML section:
<script>
window.dataLayer = window.dataLayer || [];
window.addEventListener(‘message’,
function(e) {
if (e.data.event && e.data.event.indexOf(‘calendly’) === 0) {
window.dataLayer.push({
‘event’ : ‘calendly’,
‘calendly_event’ : e.data.event.split(‘.’)[1]
});
}
}
);
</script>
- Set the Trigger to All Pages.
- Click Save.
Testing
- Enable Preview Mode in GTM.
- Book an event in Calendly.
Check the Data Layer to ensure Calendly events are captured.
Step 3: Inspect the Data Layer
Calendly sends the following key events to the Data Layer when users interact with the booking form:
- page_height
- event_type_viewed
- date_and_time_viewed
- event_scheduled (when a booking is confirmed)
To ensure these events are available:
- Open Google Tag Manager Preview Mode.
- Complete a test booking in Calendly.
Inspect the Data Layer in the preview mode.

Step 4: Create Necessary Variables in GTM
We need to extract event names and user data from the Data Layer.
1. Capture Calendly Events
- Go to GTM → Variables → Create a new Data Layer Variable.
- Set Variable Name as calendly_event.
Save it as dlv_calendly_event (for easier identification).




Step 5: Set Up the Trigger
We now need to tell GTM to fire a tag whenever a Calendly event is detected.
- Go to Triggers → Click New.
- Select Custom Event as the trigger type.
- In the Event Name field, type “calendly”.
- Choose “All Custom Events”.
- Name the trigger Calendly Event Trigger.
- Click Save.
Now, this trigger will activate whenever GTM detects Calendly events in the Data Layer.





Step 7: Create Google Analytics Event Tag
Now, we track Calendly interactions in Google Analytics (GA4).
- Go to Tags → Create a new tag.
- Choose Google Analytics: GA4 Event.
- Set your Google Analytics Measurement ID (store it in a constant variable).
For Event Name, enter:
CopyEdit
calendly_{{dlv_calendly_event}}
- (This makes the event name dynamic).
- Set the Trigger to Calendly Event Trigger.
- Save and publish the tag.
Testing
- Enable Preview Mode in GTM.
- Book an event in Calendly and inspect the Data Layer.
- Ensure the tag fires correctly for each event.








Step 6: Extract User Data (Email & Phone)
Before proceeding with extracting user data, please check the Thank You page URL. This URL carries all user details, including their name, phone number, and email address.
- Go to Google Tag Manager (GTM) Preview Mode.
- Complete a test booking in Calendly.
- Once redirected to the Thank You page, inspect the Data Layer.
- Look for the Page URL variable that contains the redirected URL storing user data.
Identify the specific parameters (e.g., invitee_email, answer_1, invitee_name).
https://www.example.com/pages/thank-you? invitee_email=test@example.com& answer_1=1234567890&
invitee_name=John+Doe

Now, we extract these details using Custom JavaScript Variables.
Extract Email
- Go to GTM → Variables → Create a Custom JavaScript Variable.
- Name it JS – Extract Email.
- Add the following JavaScript code:
function() {
var params = new URL(window.location.href).searchParams;
var email = params.get(‘invitee_email’);
return email ? decodeURIComponent(email) : ”;
}




Extract Phone Number
- Go to GTM → Variables → Create another Custom JavaScript Variable.
- Name it JS – Extract Phone Number.
- Add the following JavaScript code:
function() {
var params = new URL(window.location.href).searchParams;
var phone = params.get(‘answer_1’);
return phone ? decodeURIComponent(phone).replace(/\s+/g, ”) : ”;
}
Step 7: Create a Trigger for Google Ads Conversion Tags
Before setting up the Google Ads Enhanced Conversion Tag, we need to ensure that it fires only when a Calendly event is scheduled.
To achieve this, we will create a trigger that activates only when calendly_event equals event_scheduled.
Steps to Create the Trigger:
- Go to GTM → Click Triggers.
- Click New to create a new trigger.
- Select Custom Event as the trigger type.
- In the Event Name field, type “calendly”.
- Under “This trigger fires on”, select Some Custom Events.
- Set the following condition:
dlv_calendly_event equals event_scheduled
- Name the trigger Calendly Booking Completed Trigger.
Click Save.


Step 8: Create the Google Ads Enhanced Conversion Tag
Now, we pass the user input data to Google Ads.
- Go to GTM → Click Tags.
- Click New → Select Google Ads Conversion Tracking.
- Enter your Conversion ID and Conversion Label.
- Check Include user-provided data from your website.
- Click New Variable → Manual Configuration.
- Map the variables:
- Email → JS – Extract Email
- Phone Number → JS – Extract Phone Number
- Set the trigger to Calendly Booking Completed Trigger.
- Click Save.
Step 9: Final Check
- Ensure that the trigger fires only when a booking is completed.
- Use Preview Mode in GTM to validate that the tag works correctly.
Once validated, publish your changes in Google Tag Manager and start tracking conversions in Google Ads!
Final Note: Need More Support?
If you need any assistance with Google Tag Manager configurations, troubleshooting data not appearing in Google Analytics, or require a free audit of your setup, feel free to reach out to us.
📩 Email: hello@cortexlabs.digital
🌐 Website: cortexlabs.digital
We’re happy to help you optimize your tracking and ensure your Calendly event tracking and enhanced conversions work seamlessly!