Track users using Google analytics for one url on website - python-2.7

I have requirement where I need to store users ip, device information, user_agent, etc. information for on url on my site. How do I go about this?
This data will be used later as stats (which device hitting more, which locations etc.)
I can see that Google analytics helps in tracking for entire site.
How do I enable it to track only for one specific url on my site and track all information mentioned above?

If you add your tracking code only on the one web page you wish to track, then you should be able to accomplish your goal. Just to clarify, if you have two web pages, trackme.html and donottrackme.html, you would place the Google Analytics tracking code only on trackme.html. IP, device information, user agent, etc. should be visible within your dashboard.

Related

Display content on web page depending on Google Analytics data

Is it possible to use data from Google Analytics when someone visits my web page?
I would like to get information about the visitor, eg:
location
how many times he visited the page
from where he comes
time spent on website
etc
And depending on those informations display proper content. Or even add them (silently) to the contact form.
Is it possible to use the data collected by Google Analytics or should I create my own mechanism based on cookies? Maybe any other solution?
This isn't possible. Universal Analytics uses a cookie with an ID for the user and handles the rest on the server, so there's no data available to you. However, all of the info that Google is tracking is accessible to you.
location you can get via the users IP
visits you can get by setting a cookie on each user and tracking sessions
referrer should be in the request headers
time spent can be tracked the same way that ga does, but keeping track of the time everytime the user creates another hit

Need to track what websites a user visits after leaving my site

I would like to track what websites my site's visitors go to after they leave.
Would it be possible to place a cookie on their browser when they visit my site, and then later if they go to Facebook.com or stackoverflow.com, my cookie will retreive the browser's URL data and send it back to my server.
I could then look at this data and know that my visitors had gone to Facebook.com and stackoverflow.com after they left my site.
Is this possible using cookies?
Thanks for the help.
No. Cookies are not executed or anything. They are just dumb bits of data.
You would need to be able to execute code on the page they are visiting afterwards.
What I presume you are trying to ask, is that you want to track your outbound links.
This is mainly done with Javascript: You need to intercept click events from outbound anchor links, and send an event notification as described here, or using the hitCallbackmethod prior to completing the redirection to the external website. For Google Analytics see documentation. Or you could do via a custom JS implementation sending the info back to your server instead.
Alternatively your could replace all outbound links on the server side in your html source, and have all links pointed to your server first, and redirected to the external sites. But using redirects for this purpose is not really a good recommendation, unless you are an ad networks or a search engine company requiring such method.
Lastly, there is an alternative method using the HTML5 'ping' attribute. But the feature has been either removed and/or not yet fully implemented across all browsers as of this writing.
But you can't track where your visitors go beyond the 1st level outbound links of your site.

Retrieve user data from Google Analytics based on the __utma cookie

I am trying to find out how active are the users of my web page after registration, based on what was the source/landing page of their first visit. I would rather not try to track users myself - I am already employing Google Analytics on my web page and I know it uses the __utma cookie to tell one user from another. I can see summarized landing pages/sources in my Analytics reports but would need to have this data per specific user in the time of their sign up.
Essentially, when the user signs up with my web page I would like to retrieve their landing page and source from Google Analytics and store it in my application's database along with user's name, password, activity etc. This way I could check later, for example whether users who came from Google were more prone to buying premium service that those who came from Facebook etc.
I checked the Google Analytics API reference but it doesn't seem to provide getters for this specific data. I've been looking in up in Google and in Stack Overflow for a while.
This seems like a pretty useful functionality, which many websites should need. What am I missing? Maybe I should seek for a solution that doesn't involve GA? Or switch to a different analytics? Or track user's landing pages with cookies myself?

Displaying Own Data Using OAuth2 and Google APIs with No Login

I am trying to build an application with ColdFusion.
I've been reading documentation and trying things out for days and for the life of my I can't seem to figure out how to display my own data to users from Google's APIs using OAuth2.
For example, I want to be able to display some of my stats to users with the Google Analytics API. How many unique hits, page views my site gets and from what countries. The data is private, however, so there isn't a way to do so. Or YouTube just changed their API so video tags can no longer be seen unless logged in. I want to be able to show my video tags so they can search for related things on my own site, but I can't pull them because I'm unsure of how to do this.
I know how to display and manipulate public data, but when it comes to private data, I'm at a complete loss. OAuth2 is kicking my butt!
Is there anybody that can please, please help me with OAuth2 so that I can allow my users to see my private Google data without there being any kind of log in process for them? Examples using ColdFusion would be so much appreciated.
The answer is more or less what I said at How to retrieve my own private playlist through YouTube API?
You'd want to use the OAuth 2 for Installed Applications flow, and generate new access tokens via your refresh token when your old access token expires. I'm not familiar with any libraries for doing OAuth 2 in Cold Fusion, though.

Offline testing of OpenGraph / 'Like'

How can I test the 'Like' button functionality and OpenGraph data embedded in my pages while my site is not publicly accessible?
I have an internal test environment where my site is being built and tested. The environment is locked down by IP to a certain set of machines. I want to be able to verify the end-to-end scenario of performing a 'Like' and seeing the parsed OpenGraph data on a user's Timeline without having to open up my site to public access.
I know there's a user agent for the Facebook crawler, but allowing by user agent is risky as anyone can send any user agent string. Ideally, I'd like to lock it down to Facebook's crawler's IP range without having to parse logs to find what one or two of those IPs might be (I assume there's quite a few machines crawling the web for data).
My problem today is that I can click 'Like' and have it show up with a plain URL back to my site, but the crawler can't reach me since the page effectively doesn't exist for it when it hits my server.
How can I test the 'Like' button functionality and OpenGraph data
embedded in my pages while my site is not publicly accessible?
You really cannot do that. It has to be lint-able by Facebook. See: https://developers.facebook.com/tools/lint Be sure your page is publically avaible and able to be linted by the facebook linter tool.
This works fine with four social network previews: https://chrome.google.com/webstore/detail/open-graph-preview/ehaigphokkgebnmdiicabhjhddkaekgh?hl=es
It doesn't support the like button, just the preview.
From my localhost...as "proof of solution"