Custom Google Campaign Tracking - google-analytics

I'm building out a site that has predefined affiliate ids that are driving traffic to our sites. We currently use this paramater to track our seo work internally. Now we want to do the same through Google's Campaign Tracking at the Session level. The problem is we don't want to change our url, is it possible to manually build the Google campaign tracking pixel url? I'd like to take our affiliate ids and convert them over to a tracking campaign pixel for Google.
Seems like Google built this so all the tracking data must be in the url, is there a way to do the same tracking w/o the google data in the url?
Instead of:
http://www.mypage.com/?utm_source=google&utm_medium=cost-per-click
I want to use(javascript will do the rest):
http://www.mypage.com/?affid=123456

Turns out here is exactly what I was looking for:
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking
This is essentially doing everything the Google Campaign Tracking does but you have full control over what parameters are passed in the tracking pixel. I don't have to change or mess with the url, our in house tracking will work as it should, and now the google tracking pixel will be built as I specified.

You can programmatically set up a virtual pageview based on the affiliate id.
In an if statement, determine if you have an affiliate id. If you do, write some logic to build out the proper campaign, medium and source, then concatenate it to your URL. Pass that to GA via the trackPageview method instead of letting it do it's own thing.
Keep in mind that passing a virtual URL does replace it's default behavior, so you won't have the affid parameter in your content reports unless you build it in to the virtual pageview.

Related

Track external search form in Google Analytics/GTM

We have a search box on our website that searches a product we subscribe to. It's hosted on the third party's server, not on our domain.
Since it's just embedded on our site, I can't use Google Analtyics' built in configuration for tracking site search.
Is there another way I can track the terms used to search in the form, using either Google Analytics/Tag Manager?
yes, you can use GTM if the search query is entered on your site. Let's say, using a trigger on the search CTA click, you can then use a custom JS variable where you get the value of the search field using JS, use that variable in a GA event tag and there you have your value logged in GA.

How do I stop these self-referrals and get accurate referrals from our cross-domain eCommerce data?

Basically, I work for a theater and we send patrons to our primary website (we'll call this theater.org) to look at events and choose what tickets to buy and when they go to purchase tickets, we have put links in our primary webpages to our ticketing platform (we'll call this tickets.com).
Now, I have set up cross-domain tracking so that I can see people once they get onto tickets.com and see if they purchase a ticket. Great! But I can't really see where those people are specifically coming from because the referral source is always theater.org. I would like to see the original referral to theater.org that led to the purchase on tickets.com.
Here's what I've tried:
I've added the allowLinker (true) and the cookieDomain (auto) to my cross-domain Google TagManager
I have added both domains to the Referral Inclusion List (now I just get "direct" as the source for my eCommerce transactions instead of theater.org )
Additional info:
I have used the Analytics debugger console to see that the user-id changes as I move from one of my domains to the other, so that's definitely the primary issue
I see correct referrals on my Page Views for the theater.org , but not tickets.com
You need to make sure both tickets.com and theater.org both use the same Google Analytics property ID (UA-XXXXXXX-X) and have cross-domain tracking configured in the GTM container for BOTH domains.
Then you can look at the acquisition report tp get a sense of how people are arriving at your site OR dimensions like "previous page" or segment your goals by sessions that have visited a specific page.

How to pass gclid parameter manually in JS to Google Analytics

I have a website build with one of the most amazing frameworks on the world. Unfortunately it has one downside. It does not allow to use query parameters, for example: www.url.com/page/1 is ok but www.url.com/?page=1 is not ok. When you put this URL it uses browser history so there is no query parameters left in URL.
I have a campaign in Google Adwords that directs users to this website. Auto tagging is on. I've noticed there are 10k clicks to my website, but Analytics does not report such number for Adwords source.
I discovered that Adwords auto tagging is adding gclid parameter to the destination URL. Than, Analytics knows everything about the campaign because Analytics and Adwords are linked together and i should have pretty analytics data on campaigns and their conversions.
But i don't have it. Since my one of greatest website frameworks removes with its JS code the gclid parameter, Analytics does not notice the gclid and not save the source of the user.
To check if it is really my great website framework issue, i've added utm(umt) parameters to my website and checked source in real time in Analytics. It was not reported as source i provided in parameters but a direct visit.
I would like to be able to analize Adwords performance in Analytics. I can not change unfortunately my framework because it is one of the greatest on the world. But i have noticed that before JS code of the framework is fired i have for a while a URL with the parameter gclid.
Some lines below i have my Google Analytics tracking code. Obviously it tries to get gclid from the URL. But it is too late for him. The gclid parameter is gone when Google Analytics tries to read it.
So my question is: since i have gclid, is there any method of Google Analytics to pass it to him? Like say:
var gclid = getGClidBeforeItsToLate(); // i have it covered
// Awesome framework stuff
HeyGoogleAnalyticsHereYouGoItsYourGclidTakeCare(gclid);
?
Override the "location" field and append the gclid parameter.
if(gclid) {
ga('set', 'location', document.location + '?gclid=' + gclid);
}
ga('send','pageview')
You have to use the location field, not the "page" field (which takes the page path), since the latter does not change attribution even if you add parameters t the path.
If you have manually set campaign parameters ("utm parameters") you could set them via the campaignMedium/campaignSource/campaignName fields, but since you cannot get the individual campaign values from the gclid you have to overwrite the location (at which point GA will dismiss what it has gathered from the address bar of the browser and use the value you passed in).

tracking users with google analytics after they leave my domain to make a purchase and come back

I would like to track where users originally came from when they make a purchase on my site so I know which keywords are more profitable and which websites are best for advertising.
an example is a user is on my site with my google analytics tracking code which has details of where they came from, and then decides to upgrade. they leave my domain to go to my biller (2checkout) complete the purchase and return to my thank you page.
I have transaction code and analytics code on my thank you page and the transactions are showing up with the correct product/amounts in GA however there is no other data and in my reports the referring url is always my biller or a credit card companies authorisation page.
i can manually connect which customer is which by saving their referring data when they first come to the site and then matching it up after they make a sale, but I would like it to show up in my google adwords / analytics account where it is easier to manipulate the data and see trends.
if anyone can help me with this annoying issue I would be vbery greatful, but I fear I may end up living off reports I create and then matching them up with adwords manually :/
One thing you can do is have a click event trigger a custom variable. When the user clicks on whatever link that takes them to your biller, have the custom variable trigger with the information you want to carry over (like the current page URL, some campaign name, whatever). Specify the custom variable's scope as Session or Visit so that it get associated with the thank you page.
http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
An alternative is to do campaign tracking:
http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55540
That is more or less the same principle as the first suggestion, but with using specified URL parameters. Depending on how your pages are actually coded, you may need to push a virtual page view with the campaign code(s):
http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55521

google analytics tracking in iframe feeding to different partners

our partners sites leverages our iframes in their own websites. I was wondering if there is a way to track the analytics on the iframes.
The problem is, if we also utilize these iframes on our own website, how do i avoid duplicate tracking where a visit is counted on our domain's analytics and also counted again in iframes? is there a way to get around it?
Adding the Google Analytics code to the iframe should work just fine. The easiest way to avoid duplicate tracking is probably to add a query parameter like ?partner=foo to the URLs that your partners use. You can check for your own site's value and not run the Google Analytics code at all, and also pass the partner ID to Google so that you can break down the reports by partner.
EDIT
Use ?utm_source=foo as the partner parameter, and Google Analytics will pick it up without you doing anything. Filter out your own impressions with
if ( location.href.indexOf("utm_source=mysite") < 0 )
{
// Google Analytics code here
}
or you can set up a filter on your Google Analytics profile to filter them out.
You can also add utm_nooverride=1 to your iframe source tag. This will make sure that the page that called your iframe on the 3rd party site will not get credit for the referral, but rather the initial source (AdWords campaign, search query, etc.).
Example:
<iframe src="mypage.html?utm_nooverride=1" width="1" height="1"></iframe>

Resources