google analytics tracking link clicks - javascript

I was wondering how would i go about adding a simple tracking to a certain link on a site I am developing for a client
I am using google analytics for tracking the source of the incoming traffic and after the visitor has entered the site he supposed to click on a link, I an interested in knowing how many clicks I got from every source.

You're looking for "Campaigns". There's an extensive article about it here: http://support.google.com/analytics/bin/answer.py?hl=en&answer=1239239
You can use the "URL Builder" tool to create a URL for a specific link (on an external site, presumably) by giving a name to your campaign and other details. The parameters are utm_source, utm_medium, and utm_campaign in particular.
I'll mention that Analytics will already tell you (without any modification to the link) what referring page sent a visitor, so you can tell what page a visitor was viewing before arriving at your site. All this is found under "Traffic Sources" in the Analytics reporting interface. The utility of campaigns is if either (a) you'll be scattering links in ads on many different websites, and it's the ad rather than the page that you want to track, or (b) there may be multiple links to your site on the same page and you want to know which one the visitor clicked.

Related

How to detect who visit my website from instagram

I created a website with php and put my websites link in my instagram biography. How can i detect which instagram account visit my website from my instagram biography?
It would be difficult to track which user has visited, yet we can gather some analytics like clicks on your website using Google Analytics. You can create Events in that and trigger them after some time(like 3-5sec).On the GA Dashboard then you can see these analytics. Similarly you can gather other informatics.
This is basically related to your web functionalities, getting info of instagram user however I think it's not possible as far as i know.

Artificial pageview pushed to Analytics is changing PPC traffic source

So basically, we are having issues with a website (https://thesoundshop.com) in which the PPC traffic source (it only seems to be PPC traffic that is affected) is being changed by the pageview that we are pushing through to analtics.
The website runs on Ajax so we have to use Javascript to emulate pageviews through to Analytics whenever a link is clicked on the website. We are not using Google Tag Manager to implement the analytics or javascript because of this so we are using the gtag method exactly as Google's documentation recommends:
gtag('config', 'GA_TRACKING_ID');
I have tested this by visiting the website through a PPC ad and watching the real-time reports in Analytics. The first page load attributes the correct source to the traffic (cpc) as expected but then when I click on a link to go to a different page, the traffic source changes to Google Organic search. I then complete an action that I know will trigger an event or a goal and then when this appears in the Goal Reports, it attributes the goal as organic, too.
We know that this has to be down to the Javascript pageview that is being pushed to analytics to simulate that a new page has loaded but we can't work out why it would be changing the traffic source. The gtags are implemented exactly as Google recommends; just wondering if anyone else has had this problem and if so, how did they go about fixing it?
We had the same issue and after some more research found the problem along with the solution, thanks to Simo.
Basically, you need to manually set the document.referrer of the first session to make sure it persists and does not get over-written half way through the session. It's a known issue with GTM and single page applications.

Embed page source code to website

I would like to know how to embed page source code to my personal website.
I want to show how many YouTube subscribers, Linkedin Followers, Instagram Followers etc. I have on my personal website (I'm using Squarespace).
If you go on a YouTube page, right click 'View page source' then search for the subscribers. Is there a way of extracting this code so it updates automatically on my website every time I get new subscribers.
It would be great if I could keep them all is the same style like I have on my homepage (I have just manually typed the numbers in for now) under my showreel.
http://www.tierney.tv/
Thanks in advance,
Michael
There is no way to just "embed" code and just display specific information of an account unless someone has created it as a plugin in the type of website you are using. You would have to create API access and requests. Here is the way to Authorize Requests. https://developers.google.com/youtube/v3/code_samples/javascript
Here with your Channel ID you can get a snippet to get your subscriber numbers.
https://developers.google.com/youtube/v3/code_samples/code_snippets
These widgets should be made and supported by respective companies/sites. They can also be found there with respective links to embed the widgets.
Ex - youtube, facebook, google maps have embed codes provided to embed their videos, posts, maps.

How to use trackPageview in Google Analytics?

I need help in configuring the _trackPageview in the Google Analytics. I want to track how many times a file has been downloaded. According to Google Analytics documentation I need to use the following onClick event in the download links.
<a href="http://www.example.com/files/map.pdf"
onClick="javascript: _gaq.push(['_trackPageview', '/downloads/map']);">
But I could not find any information that after adding this, where I can see the download stats for this link? Do I need to configure anything in my Analytics account? Thanks.
That should work, and you shouldn't need to configure anything in Analytics. You will not see the events appear in the Analytics account immediately. I'd give it 24-48 hours to start showing up.
All clicks should be tracked from when you install the code. It may show up under Top Content, or you could filter visited pages by a partial URL.
Because of the delay inherent to Analytics, it's not uncommon to second-guess yourself when you try a new tracking technique. It's important to follow up and confirm the events are registering.
Edit: More info regarding _trackPageview vs _trackEvent...
_trackPageview: "Google Analytics' _trackPageview is a function for use on ga.js tracked sites that allows you to track events on your site that do not generate a pageview."
_trackEvent: "Event Tracking is a method available in the ga.js tracking code that you can use to record user interaction with website elements, such as a Flash-driven menu system."
My suggestion is that if you have a number of different downloadable files that you want to track, look into _trackEvent. If you only have one or two files to track, _trackPageview is definitely suitable. My thought is that when you have a larger number of files to track, _trackEvent will let you track by category (file download), action (hyperlink click), and label (map), which may be more useful if you're interested in downloads as a whole.
_trackEvent is also ad hoc in that whatever you code you write should auto-generate the corresponding report items without any configuration in Google Analytics.
More info (above quotes taken from these pages):
_trackPageview: http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55597
_trackEvent: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
If you want to make sure your tracking is working but don't want to wait 24-48 hours then go to the Real-Time (beta) tab in the Google Analytics sidebar.
Visit the website on another tab and, once you see that the 'Right now' indicator shows your presence, click on your download link. If you see it show up in the 'Top Active Pages' then you're good to go, gilded and golden.
You can also use the debug version of ga.js to diagnose errors. It prints things like "Invalid tracking code" and so on to the Javascript console.
Search for "Debugging with ga_debug.js" on this page:
https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting

How do I track visits to facebook pages using Google Analytics or Yahoo Web Analytics?

I have recently looked into this and discovered that using FBML pages in a facebook fan page, I can add fb:google-analytics tags or image tags to track page visits. However I have found no method of tracking visits to other facebook tab pages, like "pictures" or "wall".
Is there a way do this?
Thanks
There is no way of doing this with Google Analytics.
There used to be a hack that embedded a php file as an image, and that request tracked a pageview. However, a change to how Facebook renders pages makes this hack/plugin useless (it looks like it stopped working on September 7th). Basically, it looks like they're caching any external images onto their own servers, and thus breaking this hack. Short of there being an officially supported plugin, or Facebook allowing Google to track more, this is likely a dead end.
Edit: With Facebook tabs, you can install an iframe app as a tab (not using FBML), and you can put Google Analytics on the tab. But, since its an iframe, you don't have access to real referrer information, and Facebook spoofs its referrer, so there's no way for the iframe to detect anything about the page. But this is only for the tab, not for the wall or photos.
Another important thing to note is that the cookies are still being set on your domain, so it might make sense to keep the account on your main account, but use a special configuration on the tab.
Here's the best practice I've settled on for putting Google Analytics on a Facebook tab iframe:
First, the iframe URL should contain the URL parameter ?utm_nooverride=1. This is so if the user already has referral cookies (for example, if they got to your site before via Google, the pageview will persist with that referral source.)
Second, I override the referrer value (which is useless, since it is spoofed by Facebook) to be tab.facebook.com, to make it simple to differentiate from other traffic.
Finally, I place 2 custom variables: One page-level, and one visitor level. The former allows me to easily know what pageviews occurred from within the tab. The second allows me to track the rest of the interactions my site has with this person if they end up returning to my site. That code looks like this:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-1']);
_gaq.push(['_setReferrerOverride', 'http://www.tab.facebook.com']);
_gaq.push(['_setCustomVar', 1, 'is_facebook_page', 'true', 3]);
_gaq.push(['_setCustomVar', 2, 'visited_facebook', 'true', 1]);
_gaq.push(['_trackPageview']);
Facebook does provide some limited analytics capabilities called Facebook Insights:
http://www.facebook.com/help/?faq=15221
Also outgoing links will be tagged with a tracking code so you can pick up which traffic is coming from your Facebook pages to your site.
However you cannot embed Google Analytics or Yahoo Analytics directly into the pages.

Categories