1
votes

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

3

3 Answers

6
votes

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.

4
votes

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.

0
votes

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.