How to track UTM parameters in all the pages? - google-analytics

If the user comes with the utm values to the landing page
http://example.com/landing.php?utm_source=Facebook&utm_medium=Marketing&utm_term=FbAd&utm_content=Fad1&utm_campaign=FBFunnel
In the Landing.php file I can Get the UTM values. and Google analytics will show campaign results and clicks. What if the user navigate to other page
-> http://example.com/contact.php. In the contact.php there is no UTM values in the URL how would Google analytics track that visit from which UTM Campaign? . If I am using PHP api to send utm values to third party tools means How would I fetch UTMs in the contact.php file? I don't have clear idea about this Please help.
Thank you

Google Analytics stores campaign data, including utm parameters, in a session scope. The values are retrieved at the first page of the session (which also means that a new session starts when the campaign attribution changes) and are applied to all subsequent hits.
With the current version of GA - Universal Analytics - attribution happens on the Google servers (used to be different with previous, but now deprecated versions of GA). There is no realistic way to retrieve the Attribution data from Google in realtime. You'd have to create your own solution to store the utm paramaters in a cookie and retrieve them from there.
If you do not need to send the data in realtime I wrote a lengthy tutorial on how to extract attribution data from GA and send it to another application via the respective APIs. The tutorial uses Python as programming language and Salesforce as partner application, but there should be enough background in there to apply the principle to other languages and applications.

Your best option is to write a small piece of javascript to store the UTM values in a cookie and then populate your forms with the stored values.
If you don't want to write one yourself, this blog post helps you do exactly what you need and also provides a javascript that you can add to your website.
Disclosure: I'm the author of the blog post.

Another simpler way is to use Javascript to append the UTM/query parameters to every link. Here's an example in JQuery:
$('a').each(function() {
var querystring = window.location.search.substring(1);
var href = $(this).attr('href');
if (href) {
href += (href.match(/\?/) ? '&' : '?') + querystring;
$(this).attr('href', href);
}
});
Of course you could specify/select a class of links if you only want to keep the parameters on
This makes for uglier URLs throughout your site but may be a quicker/simpler solution than storing and accessing the UTM params in cookies.

Related

Reference an e-commerce order to cookie consent via UTM

Is it possible to reference an e-commerce order in WooCommerce with info about if cookie consent was given from the customer who made the order?
My idea is the following:
Let's say a user comes from an Ad, so the URL already contains UTM parameters.
The user then sees the cookie banner and clicks on "accept".
The "accept" button appends another custom UTM parameter (e.g &consent=1) and opts-in
There are a few plugins that make it possible to see the UTM data for a specific order (e.g "handl utm grabber"). I was wondering if this way I could get insights for a specific order if the customer gave cookie consent or not.
Also, would appending the custom UTM parameter cause any problems (e.g double counting) in Google Analytics in this scenario?
Parameter "consent=1" is not UTM parameter, so it won't start new session.

Firebase long dynamic link analytics

The Dynamic Links documentation states:
If you don't need to track click data and you don't care if the links are long, you can manually construct Dynamic Links using URL parameters
I'd prefer to use the long URLs (easier dynamic creation) but the above docs imply I'll lose click data. The campaign parameters can still be given to this URL, and the link is still hosted at Firebase, so it's not clear to me which analytics we'll lose here. Does anyone know the full details on this statement?
Firebase team responded that the UTM data is still recorded, it's just the click count which is lost in the Firebase console.

How to find adwords GCLID id in google analytics and link it to conversions manually?

I'm using a 3rd party tracking software (tracking202) to track conversions (as I can use the google conversion tag directly on my site, for some reason). Now, I've complete tracking data including keywords, placement and IPs of the converted users. Now, since Auto Tagging is enabled in my adwords account, google used glid id on my URLs since the beginning. I want to upload conversion data to adwords through the offline conversions import feature. And for that, I've 2 queries:
Where do I find the gclid ID in google analytics?
How do I link the converted IPs with GCLIDs ? (Since I have the converted IPs list in tracking202, if there's a way to filter IPs in google analytics and set the GCLID as the secondary dimension.. I would be able to collect the converted GCLIDs. But I'm not sure if its posisble in google anlaytics.
Please suggest what I can do in this case. Thanks a lot.
Google Analytics does not make the glcid accessible via the interface. If you want to get at the gclid you would have to store them yourself in a session scoped custom dimension (obviously this will not work for data already collected).
You need to create the custom dimension in the property settings (under "Custom Definitions") and then add a bit to your tracking code (poorly written PHP code for demonstration purposes only):
ga('create', 'UA-XXXX-Y', 'auto');
<?php if(isset($_GET['gclid'])) { ?>
// Set value for custom dimension at index 1.
ga('set', 'dimension1', $_GET['gclid']);
<?php } ?>
// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');
i.e. "if there is a query string variable called glcid assign it's value to the custom dimension with the numeric index 1".
Technically the same works for the client IP address (which is likewise not displayed in the GA interface or exposed via the API). However you must not (as stipulated by the Google TOS) store information that allow to identify a user in Analytics (it might depend on your legislature if IP addresses are personally identifiable information. I don't know Googles stance on this, but it would be illegal in the Europe, at least without explicit consent of the user).
You may however store an anonymous identifier that allows to pull information from GA and connect it to information stored in other systems, so if you store e.g. the strongly hashed IP both in GA and in your other tracking system then you can use this as a key field to merge the records outside of GA.

Google Analytics in real time for personalization

Is there a way in Google Analytics to get a visitors information in real time in order to personalize content?
For example, visitor A comes from Google using the "widgets" keyword and using a Chrome browser so I want to show him content related to Chrome based widgets.
Google Analytics provides a Real Time Reporting API as a developer preview in limited beta.
Real Time Reporting API Private Beta access request form.
With all the limitations that this means it may be worth giving a try.
You can find Java, PHP, and Python code examples on the documentation page: https://developers.google.com/analytics/devguides/reporting/realtime/v3/reference/data/realtime/get
In PHP this is the anatomy of the call to the API:
$optParams = array(
'dimensions' => 'rt:medium');
try {
$results = $analytics->data_realtime->get(
'ga:56789',
'rt:keyword',
$optParams);
Probably not. Even if you request from the the Real-time API keyword you will find that. The Keyword returned is the Keyword from your own campaign tracking. So this would only work on links that you sent back to yourself Which really isn't what you want to do. Its a nice idea really
Documentation: rt:keyword
When using manual campaign tracking, the value of the utm_term
campaign tracking parameter. When using AdWords autotagging or if a
user used organic search to reach your property, the keywords used by
users to reach your property. Otherwise the value is (not set).
What you are looking for is the keyword that would be used against a search engine. That keyword isn't returned via the Real-time api.

Best way to generate an automated report in Google Analytics for a specific collection of URLs

Currently using Google Analytics as a supplement to our paid tracking software, but neither of them are giving us exactly what we need.
I have a list of about 60 or so urls (out of about 1500) on the site that I wish to setup a monthly report for that can be emailed to multiple recipients. I can't seem to figure out how to create a report showing just the hits on these 60 urls, I can apply advanced filters on the content page but those disappear after a while and sometimes error out when adding too many URL's.
Is there a method I'm missing in Google Analytics to achieve this goal or am I better running an SSIS package to pull the URL's from the API and formatting a document that way?
Yeah, advanced filters are not really designed for this kind of thing.
Here are some things which may work for you:
Try setting up a new GA Profile with an Include filter to filter only the URLs that you want to report on. You can use a regular expression to identify the 60 URLs. Then these will be the only URLs tracked in that particular profile.
Try setting up an Advanced Segment to select the Pages using a very long "OR" filter.
You could set up a new GA account and log the URLs into that account with additional tracking code. This is not really recommended as the 2 accounts will share tracking cookies.
Use Excellent Analytics to pull down data into Excel for the URLs in question using the GA Export API.

Resources