开发者

Google Analytics - multiple domain tracking

开发者 https://www.devze.com 2023-01-18 22:00 出处:网络
Could anyone clarify how the GA actions _gaq.push([\'_link\', <href>]); and _gaq.push([\'_linkByPost\', <form>]); work?

Could anyone clarify how the GA actions _gaq.push(['_link', <href>]); and _gaq.push(['_linkByPost', <form>]); work?

I'开发者_高级运维m not interested on how to use them as presented in the documentation. I understand those scenarios. I want to know more about what they do when called.

Edit:

I suspect how this works but I need some confirmation from someone that fiddled with this longer than me. I want to know what the process is in each of the cases in small steps. I know that it changes the sent data in order to overwrite to cookie on the target site, but I need to know exactly the actions that happen (in terms of JavaScript on the sending page) after you do the push.

I would also like to know if I could use _gaq.push(['_link', <href>]); from anywhere in my code to change the page.

Thank you, Alin


We will assume _gaq.push(['_setAllowLinker', true]); used on any needed page.

What _gaq.push(['_link', <href>]); does:

  1. Appends the __utm<x> cookies to <href>. You need to return false in the onclick of the anchor so that the original link does not follow through.
  2. Changes the browser location to the newly formed URL.

What _gaq.push(['_linkByPost', <form>]); does:

  1. Changes the action attribute of <form> so that it includes the __utm<x> cookies.

What happens on the target page:

  1. The GA script on the target page checks the received parameters and if the __utm<x>s are sent it overwrites its own cookies with these. This results in identifying the user as being the same on that left your original page.

As a bonus _gaq.push(['_link', <href>]); can be used in (almost) any situation window.open(<href>); can be used.


They pass the cookie information from one domain to another; in the instance, it does this by appending a query string on the next page; with _linkByPost, it sends the cookie information as GET parameters on the form action along with your POST data.

If _setAllowLinker is set to true on the target page, the cookie information sent will overwrite the default Google Analytics cookies on the target page, and will allow for linked, consistent session information between the two, as the cookies will ensure that consistent data is shared.

EDIT:

No, you can't call it from anywhere in your page, unless you bind it to an onclick of where you'd like it called.

0

精彩评论

暂无评论...
验证码 换一张
取 消