SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question recording url tag to database for a conversion

    Hey all,

    I've inherited a wordpress site which includes an ad extension (id) tagged on inlinks to the site (i.e. example.com/?ad_ext=100) then that extension gets recorded to a cookie (by a file called in wp-blog-header.php) and that cookie content gets recorded in a database when a conversion happens.

    The problem is though that for some reason if the person converts (submits a form) on the first page they enter on then the cookie value isn't recorded even though the cookie is made instantly. If they land and refresh the page, or click to go to another page then convert, it records the cookie data properly.

    Does anyone have any idea why this might be happening, or alternatively if the code below, which gets the cookie info prior to recording it, could be modified to have an else statement at the end which would grab the ext. number directly from the url.

    Any ideas?

    Thanks a lot.

    Pete

    PHP Code:
    function adExtNo($defaultExt '1004'){
        if(isset(
    $_COOKIE[__FSCOOKIE_PRINT_EXT])){ //Detect custom print media ad ext number
            
    $adCookie $_COOKIE[__FSCOOKIE_PRINT_EXT];
            return 
    $adCookie;
        }else{ 
    //Else detect ppc ad ext number
            
    if(isset($_COOKIE[__FSCOOKIE_PPC_EXT])){
                    
    $adCookie $_COOKIE[__FSCOOKIE_PPC_EXT];
                    return 
    $adCookie;
            }else{ 
    //Else just set ext number to web default
                    
    return $defaultExt;
            }
        }


  2. #2
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've done a bunch of research and think this code might be a lot closer but it still doesn't quite work.

    The second else{ is added and I'm trying to get it to detect if ex. ?ppc_ext=1234 exists in the URL, and if it does then set $adCookie as that variable value.

    Anyone know what's wrong?

    PHP Code:

    function adExtNo($defaultExt '1004'){
        if(isset(
    $_COOKIE[__FSCOOKIE_PRINT_EXT])){ //Detect custom print media ad ext number
            
    $adCookie $_COOKIE[__FSCOOKIE_PRINT_EXT];
            return 
    $adCookie;
        }else{ 
    //Else detect ppc ad ext number
            
    if(isset($_COOKIE[__FSCOOKIE_PPC_EXT])){
                    
    $adCookie $_COOKIE[__FSCOOKIE_PPC_EXT];
                    return 
    $adCookie;
        }else{ 
    //Else detect ppc ad ext number in url
            
    if(isset($_GET[ppc_ext])){
                    
    $adCookie $_GET[ppc_ext];
                    return 
    $adCookie;
            }else{ 
    //Else just set ext number to web default
                    
    return $defaultExt;
            }
        }


  3. #3
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just in case anyone else was in need of this, here it is thanks to HuggyEssex on digitalpoint

    PHP Code:
    function adExtNo($defaultExt '1004'){
        if(isset(
    $_COOKIE[__FSCOOKIE_PRINT_EXT])) {
            
    //Detect custom print media ad ext number
            
    $adCookie $_COOKIE[__FSCOOKIE_PRINT_EXT];
            return 
    $adCookie;
        }elseif(isset(
    $_COOKIE[__FSCOOKIE_PPC_EXT])) {
            
    //Else detect ppc ad ext number
            
    $adCookie $_COOKIE[__FSCOOKIE_PPC_EXT];
            return 
    $adCookie;
        }elseif(isset(
    $_GET[ppc_ext])) {
            
    //Else detect ppc ad ext number in url
            
    $adCookie $_GET[ppc_ext];
            return 
    $adCookie;
        }else{
            
    //Else just set ext number to web default
            
    return $defaultExt;
        }



Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •