Using Google Analytics to track the same session i

2019-02-24 11:12发布

问题:

We are implementing a 3rd party payment system into our site (Barclays CPI). We want to use Google Analytics to track where paying customers came from eg; keywords, email campaigns etc. However, the Barclays CPI returns the payment authorisation result via a server-to-server http request, not a normal web page with google analytics code. This breaks the analytics chain, we lose the client cookie that identifies the visitor.

On the Barclays CPI confirmation screen the user can press a Continue button to return to our site, where we could put javascript tracking code in, but pressing the Continue button is optional. We need 100% accurate analytics stats for budgeting, planning and reporting purposes.

Server side tracking calls to the rescue?

I know that it is possible to make server side tracking calls, eg; http://www.diaryofaninja.com/projects/details/ga-dot-net, but I want to link the server side tracking calls to the same browser analytics session so we know where the paying customer has come from and can trace his path through the site prior to payment.

Is it a good idea take the value of all the google cookies just before the user went to the 3rd party site, and then somehow attach them to the server side analytics call so that the payment authorisation result is connected to the same browser session? Is this possible?

Thanks

回答1:

Got this working. Using ga.aspx from the Google Analytics for mobile as a base you can store the original utma and utmz cookie values from the browser session and store them in a way you can retrieve outside of the browser. In my case, the order id. Then you need to make a __utm.gif image request to google to track outside of the browser. To keep the same analytics session details as the original user, get the stored utma and utmz values and put them in the utmcc parameter for the __utm.gif request. You'll need to url encode the values first eg;

url += "&utmcc=" + Uri.EscapeDataString( utma + utmz) 


回答2:

Gareth, this is just an idea; I’ve not done this before.

But is it possible to pass a unique reference to Barclays, then before the redirect to them store the cookie information in the db.

Then when you get the request from Barclays, could you read the previously passed unique reference from the request, lookup the cookie values, then do a httpwebrequest to the google analytics gif, passing the cookie values.

http://www.google-analytics.com/__utm.gif //from http pages
https://ssl.google-analytics.com/__utm.gif //from https pages

    ?utmwv=1 //Urchin/Analytics version
&utmn=634440486
&utmcs=UTF-8 //document encoding
&utmsr=1440x900 //screen resolution
&utmsc=32-bit //color depth
&utmul=nl //user language
&utmje=1 //java enabled
&utmfl=9.0%20%20r28 //flash
&utmcr=1 //carriage return
&utmdt=Linklove » The optimum keyword density //document title
&utmhn=www.vdgraaf.info //document hostname
&utmr=http://www.google.nl/search?q=seo+optimal+keyword+density&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_nlNL210NL211 //referer URL
&utmp=/the-optimum-keyword-density.html //document page URL
&utmac=UA-320536-6 //Google Analytics account
&utmcc= //cookie settings
    __utma=
                    21661308. //cookie number
                    1850772708. //number under 2147483647
                    1169320752. //time (20-01-2007) cookie first set
                    1172328503. //time (24-02-2007) cookie previous set
                    1172935717. //time (03-03-2007) today
                    3;+
    __utmb=
                    21661308;+ //cookie number
    __utmc=
                    21661308;+ //cookie number
    __utmz=
                    21661308. //cookie number
                    1172936273. //time (03-03-2007) today
                    3.
                    2.
        utmccn=(organic)| //utm_campaign
        utmcsr=google| //utm_source
        utmctr=seo+optimal+keyword+density| //utm_term
        utmcmd=organic;+ //utm_medium

The get request information is from here and here