473,545 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Google Analytics Auto-Login to deeper pages with Javascript

victorduwon
32 New Member
Hi guys and gals,

I am using javascript to autologin to my google analytics account via a hyperlink.

This is what the text looks like this

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">       
  4. <script src="/autologin.js" type="text/javascript"></script>    
  5. <p><a class="aaButton FL" href="javascript:gi('googleanalyticslogin').submit();">Sign in to Analytics Account</a></p>
  6. <form style="display:none;" id="googleanalyticslogin" action="https://www.google.com/accounts/ServiceLoginBoxAuth" method="post">
  7. <input type="text" name="Email" class="gaia le val" id="Email" size="18" value="**********" />
  8. <input type="password" name="Passwd" class="gaia le val" id="Passwd" size="18" value="***********" />
  9. <input type="checkbox" name="PersistentCookie" value="yes" />
  10. <input type="hidden" name="rmShown" value="1" >
  11. <input type="hidden" name="continue" value="http://www.google.com/analytics/home/?et=reset&amp;hl=en-US" />
  12. <input type="hidden" name="service" value="analytics">
  13. <input type="hidden" name="nui" value="1" />
  14. <input type="hidden" name="hl" value="en-US">
  15. <input type="hidden" name="GA3T" value="oCGYxISAGUE" />
  16. </form>
  17.                 </div>
  18. </body>
  19. </html>
  20.  

I got this script from askapache and I thank them for it.

This all works just fine for me. My problem is that I want to access pages deeper in the google analytics site, like Unique visitors, or Pageviews. When I try to swap the url above with the one for the deeper pages I want, I get the login page, where as the script above takes me to the profiles page that you see immediately after login. I know the problem is with the cookies google puts once you login. If I use the script above, I get the cookies from googlle, and the login works. If I delete those cookies and try to run the script with the url of the deeper pages, it goes to the login page again. However, if I do not delete the cookies and run the script with the url of the deeper page then it goes to the page I want with out a hitch. I have tried to use java to recreate the same cookies and deposit them on the computer of the person using the script before it runs, but that did not work. I also tried using a redirect but that flopped as well. I am at my wits end.

If anyone would give me some advice, help or consolation, I would really appreciate it.

Thanks

Victor
Nov 29 '07 #1
14 8612
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!
When I try to swap the url above with the one for the deeper pages I want, I get the login page, where as the script above takes me to the profiles page that you see immediately after login. I know the problem is with the cookies google puts once you login. If I use the script above, I get the cookies from googlle, and the login works. If I delete those cookies and try to run the script with the url of the deeper pages, it goes to the login page again. However, if I do not delete the cookies and run the script with the url of the deeper page then it goes to the page I want with out a hitch. I have tried to use java to recreate the same cookies and deposit them on the computer of the person using the script before it runs, but that did not work.
Cookies only work for the same domain. You could try submitting to an iframe and then going to the deeper page. That way, the cookies are set and you reach the page in "one click".
Nov 29 '07 #2
Dasty
101 Recognized Expert New Member
It's easy to explain such a behavior.

The login page you are calling (the first one that works always) is doing this:
- take you login form information and check them
- if they are right, server creates session for you (tagged as logged in), creates new cookies that identify you with that newly created session and send them to your client
- so from this point, whenever you make request to server with this new cookie, server can assign your request to your session -> you are logged in

So if:
1) you call loggin page first -> it creates session + cookies
- when you try to call deeper site now, it will work, becasue server you already has the sesion and can assign it with your cookie you are always sending in request.
- when you delete your cookies, server can not assign your request with his session anymore, so whatever you request for, you are redirected to login page

2) you call deeper site first (without calling login page before)
- you dont have cookie in your client that you are sending to server, nor server has session for you. So he is always redirecting you to login page.

I know what you want to achieve here. But it seems that google is processing your login form just in the first page, and in all others just check if you are already logged in. If not ... redirecting you to login page.

I can see just iframe solution:
1) call your login page into hidden iframe
2) and after that redirect to deeper site

But it's quite ghetto solution, because you have to wait till your iframe page is loaded, to continue ... so you maybe need 2 clicks, not one :)
Nov 29 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
I can see just iframe solution:
1) call your login page into hidden iframe
2) and after that redirect to deeper site

But it's quite ghetto solution, because you have to wait till your iframe page is loaded, to continue ... so you maybe need 2 clicks, not one :)
Good explanation.

You could show a loading image or div until the iframe page has loaded.
Nov 29 '07 #4
victorduwon
32 New Member
Thanks guys, your explanation has helped me a lot.
As far as the iframe solution, that sounds doable. I even like the idea of placing a load image in it. My goal is to make all of this happen in one click.
Could someone tell me how to create the hidden iframe and use it to load my page? I am very new to Javascript, and all of my exp comes from this project.

thanks again.
Nov 29 '07 #5
victorduwon
32 New Member
I made a post last night about a problem I was having with an autologin script. I want my users to be able to log into google analytics with only one click from another site. But I want them to not got to the landing page, (the one after login) but to pages deeper in the analytics suite, like PageViews, or Unique Views.
The advice I was given was to use an iframe to run my autologin script let google deposit its cookies, and then redirect it to the pages deeper in the site.
I have been researching this all morning, but I am new to Javascript and am not lost and confused. Would someone point me in the right direction of give me some assistance in this?
Thanks
Vic
Nov 29 '07 #6
victorduwon
32 New Member
Is there any way using Javascript that I can cause this page to load, accept cookies, but not to show? This way when the user clicked on the link it would automatically take them to the pages I want them to see in one click, because the cookies would have already been loaded when the first page was.
Nov 29 '07 #7
victorduwon
32 New Member
Hi guys and gals,

I am using javascript to autologin to my google analytics account via a hyperlink.

This is what the text looks like this

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.       <?xml version="1.0" encoding="utf-8"?>
  4.  
  5.       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  6.  
  7.       <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">      
  8.  
  9.       <script src="/autologin.js" type="text/javascript"></script>   
  10.  
  11.       <p><a class="aaButton FL" href="javascript:gi('googleanalyticslogin').submit();">Sign in to Analytics Account</a></p>
  12.  
  13.       <form style="display:none;" id="googleanalyticslogin" action="https://www.google.com/accounts/ServiceLoginBoxAuth" method="post">
  14.  
  15.       <input type="text" name="Email" class="gaia le val" id="Email" size="18" value="**********" />
  16.  
  17.       <input type="password" name="Passwd" class="gaia le val" id="Passwd" size="18" value="***********" />
  18.  
  19.       <input type="checkbox" name="PersistentCookie" value="yes" />
  20.  
  21.       <input type="hidden" name="rmShown" value="1" >
  22.  
  23.       <input type="hidden" name="continue" value="http://www.google.com/analytics/home/?et=reset&hl=en-US" />
  24.  
  25.       <input type="hidden" name="service" value="analytics">
  26.  
  27.       <input type="hidden" name="nui" value="1" />
  28.  
  29.       <input type="hidden" name="hl" value="en-US">
  30.  
  31.       <input type="hidden" name="GA3T" value="oCGYxISAGUE" />
  32.  
  33.       </form>
  34.  
  35.                       </div>
  36.  
  37.       </body>
  38.  
  39.       </html>
  40.  
  41.  
  42.  
I got this script from askapache and I thank them for it.


The problem I had is mentioned in another post. I believe that my solution is in getting this script to run when the page loads, but to not show the google analytics page. This will allow the clients machine to accept the cookies, and when they click on links to go deeper in to the google analytics site the cookies will already be in their browser.

How do I do this? Any help or redirection will be greatly appreciated.

vic
Nov 29 '07 #8
perhapscwk
123 New Member
script cannot work cross-domain.
Nov 30 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
As far as the iframe solution, that sounds doable. I even like the idea of placing a load image in it. My goal is to make all of this happen in one click.
Could someone tell me how to create the hidden iframe and use it to load my page?
Set the height and width to 0. Put the code for the form submit in the iframe.
Nov 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2360
by: FRITSCH Vincent | last post by:
Hi, i need help on a query. I've this table : create table t ( customer number(5), time date, status varchar2(1)
18
2193
by: nenad | last post by:
Wouldn't it be nice if we could do something like this: class Funky{ public: auto virtual void doStuff(){ // dostuff } };
4
10228
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT @@Identity"; // the auto-number fiels int iId = (int)myCommand.ExecuteScalar();
9
18819
by: Beowulf | last post by:
I was having this problem: http://groups.google.com/group/microsoft.public.sqlserver.server/msg/e36e423972323378?dmode=source with it taking an inordinate amount of time to enumerate the databases on my local SQL Server instance, so I went through all the local databases and unchecked "Auto Close" on the "Options" tab of the Database...
0
1077
by: Ansuiya | last post by:
hii Can any 1 tell me which is fast ? AWstat or google analytics.Google Analytics takes too much time for processing but i dnt know about AWstat.Help please.. Thanx
11
10701
by: mp- | last post by:
I want to be able to allow people to check their email from my PHP online application. Given only the users 1) email address, 2) username (if applicable) and 3) password - how can I auto detect a remote IMAP/POP3 server so that I can connect and fetch mail for the user. (Ultimately, I don't want users to have to know what the IMAP/POP3...
5
2550
by: cj | last post by:
Back some time ago I was playing with a little app in VB 2005 that used a google web service to get search results. I was rebuilding this app in 2008 today. I added the web service http://api.google.com/googlesearch.wsdl and then down in the code I was typing Dim myGoogle As New Google.GoogleSearchService only to find GoogleSearchService...
2
2342
by: laurenss | last post by:
hi i have an apllication build in vb6 that opens links like : http://www.google/userid=1 then http://www.google/userid=2 and so further .. its an dynamic hyperlink with vazriable i but now , its a difficult part ( i think) first
1
1343
by: tatipellinaresh | last post by:
Hi, I want to use visitor tracking in my web application which is similar to Google Analytics. But in case of google we have to use their script file and they will store out site's data into their server. I want to implement in similar way to google. Please anybody can give the sample code for website tracking. Thanks Naresh
0
7502
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7434
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.