How to pass gclid parameter manually in JS to Google Analytics - 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).

Related

How UTM paramters reach to Google Analystics Website

I am bit confused, and need little help regarding UTM tracking parameters.
Standard syntax of UTM url is:
http://www.example.com/?utm_source=adsite&utm_campaign=adcampaign.
Lets say I embed this url as a link in my page. User clicks this link. Link is pointing to my website.
All utm parameters would reach to my website. How do they will reach to Google analytics website.
My guess is, Analytics code and js intercept all link clicks and extract UTM params and then let user defined click handler work with the click.
Could someone with right expertise would help me?.
Thank you very much for your time, really appreciated.
The UTM require following mandatory parameters:
http://www.example.com/?utm_source=adsite&utm_medium=admedium
utm_source and utm_medium are mandatory.
utm_campaign is not mandatory even if the documentation says otherwise.
Google Analytics automatically collects these parameters and automatically removes them from the URL so in Google Analytics you will see the URLs without parameters and the source / medium of the UTM.

Is there a way map/set utm parameters in gtm?

I currently have a bunch of traffic going to my website with a query string like so: www.mywebsite.com/?source=facebook
I've installed GTM on my website and also from GTM fire a Google Analytics Page View etc. What i'm wondering is through GTM, is there a way to grab the source (facebook) from the url and set utm_source=facebook when firing the pageview tag.
Or is my only option to change all the links going to my site to be:
www.mywebsite.com/?utm_source=facebook instead?
Thank you everyone for your expert advice. Really Appreciate it.
You can fetch the parameters via an url type variable, and then use the "set fields" option in your GA tag to populate the "campaignSource" and "campaignMedium" fields. If the parameters are not present the url query variables default to "undefined", and undefined fields are not sent, so you do not need to check if values are present.

How can I view disqus comment text in google analytics?

I used rails to develop my website, and I've installed disqus and google analytics.
I would like to be able to view the content of comments made via disqus in my google analytics dashboard. Is this possible?
I've only been able to see how many 'likes' and 'comments' in the dashboard, but not the actual content.
Thanks.
If you want to record the comments, you will need to capture them in a Custom Variable to send to GA. However, note that
There is a character limit for Custom Variable values (a 128 char
limit shared between all custom var names and values on a given
request).
Tracking stuff like this isn't really what GA (or other tracking
tools) is for, and could possibly even violate Google's ToS,
depending on the contents of the comments

Track foreign url using google analytics

I have a URL(https://www.mysite.com/tab/subtab/) that belongs to my website(https://www.mysite.com/). Clearly, to track clicks on this url, all I have to do is append the utm_source, utm_medium and utm_campaign parameters to it. Now, what I want to do is, track a url http://www.notmysite.com/tab/subtab/. This url is neither a part of my site, nor is it mentioned any where in my google analytics account, only the link is available for modification. If I append the utm_* params here, the "clicks" information goes to the http://www.notmysite.com website owner's GAQ account and not mine(obviously!). What parameters should be appended to this foreign url, so that I can track the clicks on it?
If this is not possible with google analytics, are there any other options?
Thanks
You will want to look into event tracking to track clicks on links.
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#Anatomy
Taking an example from Google's doc:
Click here
Any clicks on that link will now appear in Analytics under Content -> Events. Notice though how I added target="_blank" which is needed for ensure the accuracy of events for external links due to there not being enough time to send the data to Google. A workaround is to add a delay via javascript which is a better approach if you're tracking more clicks.

Custom Google Campaign Tracking

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.

Resources