Affiliate links negate google analytics / ecommerce

Discussion in 'Troubleshooting' started by chronoshift, Oct 12, 2010.

  1. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    When you use an aMember affiliate link to make sales - google analytics ecommerce tracks all those sales as DIRECT traffic instead of the correct referrer (your affiliate site) - it seems that when you send traffic as an aMember affiliate link, your HTTP referrer goes nil.

    Is there any way to fix this?
  2. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    I'm pretty sure this has something to do with the redirection in go.php - I think google analytics just needs to be properly implemented into the affiliate side of things...
  3. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    Upon further reading it seems this may have something to do with using secure https and subdomains for your checkout... any help would be greatly appreciated
  4. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    Just received a bullshit response from support:


    Hello,
    when user clicks on affiliate link browser goes to go.php and then redirects to other page.
    GA code you have on signup or thankyou page just can not get first referrer becuase previous page is go.php or other amemebr page.


    ---

    I need a real solution to this problem, not a dumb excuse
  5. miso

    miso aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    543
    Oh yeah, you're gonna get far with that attitude, I can see that already...
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    The problem is not an aMember.
    go.php script use 302 HTTP redirect and most browsers send previous referer when when redirected in such way.
    I just tested this myself on local installation here is log of requests:
    Affiliate link was put to http://192.168.1.4/test.php Then I clicket it and was redirected to signup.php



    Code:
    http://192.168.1.4/test.php
    
    GET /test.php HTTP/1.1
    
    Host: 192.168.1.4
    
    User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10
    
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    
    Accept-Language: en-us,en;q=0.5
    
    Accept-Encoding: gzip,deflate
    
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    
    Keep-Alive: 115
    
    Proxy-Connection: keep-alive
    
    
    HTTP/1.0 200 OK
    
    Date: Thu, 14 Oct 2010 09:26:08 GMT
    
    Server: Apache/2.2.14 (Ubuntu)
    
    X-Powered-By: PHP/5.3.2-1ubuntu4.5
    
    Vary: Accept-Encoding
    
    Content-Encoding: gzip
    
    Content-Length: 82
    
    Content-Type: text/html
    
    X-Cache: MISS from dev
    
    X-Cache-Lookup: MISS from dev:3128
    
    Via: 1.1 dev:3128 (squid/2.7.STABLE7)
    
    Connection: keep-alive
    
    Proxy-Connection: keep-alive
    
    ----------------------------------------------------------
    
    http://localhost/PRO-3_0/go.php?r=1&i=l0
    
    
    
    GET /PRO-3_0/go.php?r=1&i=l0 HTTP/1.1
    
    Host: localhost
    
    User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10
    
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    
    Accept-Language: en-us,en;q=0.5
    
    Accept-Encoding: gzip,deflate
    
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    
    Keep-Alive: 115
    
    Connection: keep-alive
    
    Referer: http://192.168.1.4/test.php
    
    
    HTTP/1.1 302 Found
    
    Date: Thu, 14 Oct 2010 09:26:14 GMT
    
    Server: Apache/2.2.14 (Ubuntu)
    
    X-Powered-By: PHP/5.3.2-1ubuntu4.5
    
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    
    Pragma: no-cache
    
    Set-Cookie: amember_aff_id=1; expires=Fri, 14-Oct-2011 09:26:15 GMT; path=/
    
    Location: http://localhost/PRO-3_0/signup.php
    
    Vary: Accept-Encoding
    
    Content-Encoding: gzip
    
    Content-Length: 20
    
    Keep-Alive: timeout=15, max=100
    
    Connection: Keep-Alive
    
    Content-Type: text/html; charset=ISO-8859-1
    
    ----------------------------------------------------------
    
    http://localhost/PRO-3_0/signup.php
    
    
    
    GET /PRO-3_0/signup.php HTTP/1.1
    
    Host: localhost
    
    User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10
    
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    
    Accept-Language: en-us,en;q=0.5
    
    Accept-Encoding: gzip,deflate
    
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    
    Keep-Alive: 115
    
    Connection: keep-alive
    
    Referer: http://192.168.1.4/test.php
    
    
    HTTP/1.1 200 OK
    
    Date: Thu, 14 Oct 2010 09:26:15 GMT
    
    Server: Apache/2.2.14 (Ubuntu)
    
    X-Powered-By: PHP/5.3.2-1ubuntu4.5
    
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    
    Pragma: no-cache
    
    Vary: Accept-Encoding
    
    Content-Encoding: gzip
    
    Content-Length: 2394
    
    Keep-Alive: timeout=15, max=99
    
    Connection: Keep-Alive
    
    Content-Type: text/html; charset=ISO-8859-1
    
    
    As you can see referer was sent in signup.php request after 302 redirect:
    GET /PRO-3_0/signup.php HTTP/1.1
    Referer: http://192.168.1.4/test.php

    How did you insert google analytics code? If you include separate js file from signup template, this will lead to another http request when that js script will be loaded by browser and referer will be different in that request.
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    In fact, it is easy to fix.
    Edit file amember/go.php

    replace last line
    PHP:
    header("Location: $link");
    to
    PHP:
    html_redirect($link);
    then edit amember/templates/redirect.html and include GA code into.
  8. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    Thanks for the responses, going to try it out now

    Sorry for the bit of attitude - it's always frustrating getting a generic/excuse response the first time around
  9. chronoshift

    chronoshift aMember Pro Customer

    Joined:
    Jul 23, 2007
    Messages:
    61
    This worked for getting affiliate clicks to appear as proper referrers to get to the main page (after go.php)

    but I think the code in google_analytics.js needs to be re-written to support sub-domains (or multiple top-level domains) to get ecommerce working properly

    because sales are going through a subdomain (eg. secure.paysite.com)

Share This Page