Google Analytics自动使用Javascript登录更深层的网页 [英] Google Analytics Auto-Login to deeper pages with Javascript

查看:55
本文介绍了Google Analytics自动使用Javascript登录更深层的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计和女孩们,


我使用javascript通过超链接自动登录我的谷歌分析账户。


这是什么文本看起来像这样

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

展开 | 选择 | Wrap | 行号

推荐答案

欢迎来到TSDN!
Welcome to TSDN!

当我尝试将上面的url与我想要的更深层页面交换时,我得到了登录页面,上面的脚本将我带到你看到的配置文件页面登录后立即。我知道问题出在你登录后谷歌google put。如果我使用上面的脚本,我从googlle获取cookie,登录工作。如果我删除这些cookie并尝试使用更深层页面的URL运行脚本,它将再次进入登录页面。但是,如果我不删除cookie并使用更深层页面的URL运行脚本,那么它会转到我想要的页面。我试图使用java重新创建相同的cookie并在运行之前使用脚本将其存放在人的计算机上,但这不起作用。
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.



Cookie仅适用于同一个域。您可以尝试提交到iframe,然后转到更深的页面。这样,就会设置Cookie并以一键点击的方式到达页面。

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".


很容易解释这种行为。


您正在呼叫的登录页面(第一个始终有效)正在执行此操作:

- 带您登录表单信息并检查它们

- 如果它们是对,服务器为您创建会话(标记为已登录),创建新的cookie,通过新创建的会话识别您的身份并将其发送给您的客户

- 所以从这一点开始,每当您向使用此新Cookie的服务器,服务器可以将您的请求分配给您的会话 - >您已登录


因此,如果:

1)您先拨打登录页面 - >它会创建会话+ cookie

- 当你尝试现在调用更深的网站时,它会起作用,因为服务器你已经有了sesion并且可以为你分配你总是在请求中发送的cookie。 />
- 当您删除Cookie时,服务器无法再将您的请求分配给他的会话,因此无论您要求什么,您都会被重定向到登录页面


2)你先调用更深的网站(之前没有调用登录页面)

- 你的客户端没有cookie,你发送到服务器,服务器也没有为你的会话。所以他总是将你重定向到登录页面。


我知道你想在这里实现什么。但似乎谷歌正在第一页处理您的登录表单,而在所有其他人只是检查您是否已经登录。如果不是...将您重定向到登录页面。


我只能看到iframe解决方案:

1)将您的登录页面调用隐藏的iframe

2)然后重定向到更深的网站

但它是非常贫民窟的解决方案,因为你必须等到你的iframe页面被加载,才能继续...所以你可能需要2次点击,而不是一次:)
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 :)



我只能看到iframe解决方案:

1)将你的登录页面调成隐藏的iframe

2)和之后重定向到更深的网站


但它是非常贫民窟的解决方案,因为你必须等到你的iframe页面被加载,才能继续...所以你可能需要2次点击,不是一个:)
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 :)



很好的解释。


您可以显示加载图像或div,直到if rame页面已加载。

Good explanation.

You could show a loading image or div until the iframe page has loaded.


这篇关于Google Analytics自动使用Javascript登录更深层的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆