Google Tag Manager
By:
Raj Gurung
Published On :
March 11, 2024
Today’s discussion focuses on the process of capturing data from URLs when visitors arrive at our site via Google Ads. We’ll explore methods for storing this information in first-party cookies and delve into techniques for integrating these parameters into our forms. This enables us to track the origin of our users and determine which advertising campaigns are most effective.
We will use Event Creator which will help us to create a URL which can store valuable data such as;
==Important==
To get the data we will use a tool called Campaign URL Builder. A campaign URL builder is a tool that creates custom URLs with specific parameters to track the effectiveness of marketing campaigns. These URLs, also called “UTM parameters,” help identify traffic sources like social media, email, or ads. Marketers use them to analyze which campaigns are driving traffic and conversions. It’s a simple yet powerful way to optimize marketing efforts based on real-time data.
For more information, you can visit Campaign URL Builder
First of all, you need to visit the Campaign URL Building tool’s official website.
In the URL builder, you can see many fields you can use to send information about your campaign.
The most important step you need to do is to Toggle the button from UA(universal analytics to GA4(Google Analytics 4)
After choosing the GA4 you can now able to send the data which is compatible with the GA4 events. As you know Google has decided to phase out Universal Analytics so you need to choose the GA4 option
Now you need to fill in the information that the site has asked such as; campaign ID, campaign source, campaign medium and others.
In our case scenario, here are the options that we have chosen;
All of the data that we have provided in this blog are examples, you need to input your actual data inside the fields
After you input all of the data inside the field you, the site will create a link for you with all the information provided above.
Now you need to copy the link and post it in your ads campaign in Google Ads.
Now Tag Manager will create the following things;
The URL variable is needed to get the data from the URL and we can also create multiple URL variables to get value for the multiple parameters.
To create the URL variable ;
After the variable is created, you can give the variable a name and save the variable.
Similarly, you can create multiple variables using the same method.
To create the cookie we will use a Tag Called Cookie Creator which you can find in the Community Template Gallery.
To create the tag;
Now you need to search for the tag called Cookie Creator
Now choose the Template and provide all the permission that the tag requires.
Inside the tag, you will need to fill out the name of the first-party cookie and the value of the Cookie
Choose the following;
Cookie name : “__gtm_campaign_source (can be changed)”
Cookie Value : {{UTM-utm_source}} (the URL variable you created)
Now for the trigger you can choose All page view trigger
Save it
Before configuring the tag, you need to provide permission to the cookie name that you have chosen.
Now Give the tag a name and save the tag and the trigger.
Now you need to create the first party variable which will store the value from the cookie creator into a variable.
Now Finally you need to create a script which will fill the form with all the value that you provided from the cookies
<script>
(function () {
var value = "{{campaign_source_cookie}}" //fill with variable which information should be written into the field
var selector = "input[id='evf-95-field_JNPHrL43Tl-7']" //fill with CSS Selector that identifies the form field
var field = document.querySelector(selector)
if(field){ field.value = value||"(none)"; }
})();
</script>
In the above choice you need to look after the following things;
Now for the trigger, we will need to fire this trigger where the page view is DOM ready.
Save all the Tags and trigger.
Now you need to create a form in WordPress where the value can be stored. It can be a hidden text field as well. but for our example, the fields are not kept hidden
==You can choose any forms plugins to create a form as long as it is not a iframe==
Now you can test the tag by going to preview;
Now you can fill out your form submit the request and see the result in the entries section of your form.
After configuring the GA4 tag, use the “Preview” mode in GTM to test its functionality.
In conclusion, by importing UTM parameters into cookies and embedding them in forms, you’ve set up a robust system to monitor user behaviour and traffic sources. Some of the important things that you need to look at are;
Let’s talk about your business goal and align the solution we provide with our digital marketing services.
FREE strategy call© Humming Web. All Rights Reserved