1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

facebook ads GET params

Discussion in 'FaceBook' started by bizbez, Aug 12, 2012.

  1. bizbez

    bizbez Registered Member

    Joined:
    Jan 26, 2011
    Messages:
    86
    Likes Received:
    3
    hi all,

    i want to buy FB ads, and be able to know which ad did convertion,
    in order for that to happen, i need a way to pass the ad params into my page (i will send it via form to my DB).

    my question - how do i pass the ad params to my FB page - the page is iframe of a page from my site.

    thanks a lot,
     
  2. kiggd

    kiggd Junior Member

    Joined:
    Apr 28, 2012
    Messages:
    116
    Likes Received:
    44
    Unfortunately, I don't think Facebook passes any ad parameters to the target page when someone clicks on an ad. Which yes is lame because you can't really see what happens from people clicking specific ads.
     
  3. Knorc

    Knorc Newbie

    Joined:
    Jul 24, 2012
    Messages:
    11
    Likes Received:
    2
    When you create an ad, you have a field called "URL tags" or something like that.
    It is available only for certain types of ads.

    Just enter something like ad=myfirstad (or whatever you want to differenciate them)

    Here's a custom code I created if you want to track it with Analytics :

    <?php


    if ( isset($_GET["ad"]) ){
    $gga='utm_source=facebook&utm_medium='.$_GET["ad"].'&utm_campaign=facebook_ads';
    echo '<script type="text/javascript">
    document.location.href+="#'.$gga.'";
    </script>';
    } elseif ( isset($_GET["fb_source"]) ){
    $gga='utm_source=facebook&utm_medium='.$_GET["fb_source"].'&utm_campaign=facebook';
    echo '<script type="text/javascript">
    document.location.href+="#'.$gga.'";
    </script>';
    }
    ?>

    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_setAllowAnchor', true]);
    _gaq.push(['_trackPageview', '/mypage_._p_h_p']);
    _gaq.push(['_trackPageLoadTime']);

    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('h_t_t_p_s_:' == document.location.protocol ? 'h_t_t_p_s_:_/_/_ssl' : 'h_t_t_p_:_/_/_w_w_w') + '.google-analytics_._c_o_m_/ga.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
    })();
    </script>


    Just customize everything in bold (also remove underscores). This code will get the "ad" parameter you passed, and transform it in order to pass it to Analytics.
    If there isn't such a parameter, it will get the "fb_source" parameter passed by Facebook to know exactly where you visitor comes from in Facebook. (appcenter, notification, search, feed, ...)