facebook ads GET params

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

  1. bizbez

    bizbez Registered Member

    Jan 26, 2011
    Likes Received:
    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

    Apr 28, 2012
    Likes Received:
    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

    Jul 24, 2012
    Likes Received:
    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 :


    if ( isset($_GET["ad"]) ){
    echo '<script type="text/javascript">
    } elseif ( isset($_GET["fb_source"]) ){
    echo '<script type="text/javascript">

    <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']);

    (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);

    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, ...)