So my wordpress site has a one header and one footer with a big CTA as one of the menu items. I want to create a bunch of landing pages but I want to be able to change the offerid in the url for each landing page for that big CTA so I can track.

By offerid I mean http://www.example.com/customers/?offerid=weyhw68963.

I'm am stuck on how to do this since the menu is a global menu and the link is the same on every page. My thought is that I would make a condition in the header.php file because I'm using bootstrap and I activated the menu in the header file.

    if(is_front_page()) {
        $args = array(
              'menu'         => 'header-menu',
              'menu_class'   =>'nav navbar-nav navbar-right',
              'container'    =>'false'
      } else {
        $args = array(
              'menu'         => 'page-menu',
              'menu_class'   =>'nav navbar-nav navbar-right',
              'container'    =>'false'
      wp_nav_menu( $args );


I'm thinking something like starting with is_page("offerid") then using custom_key but to be honest I'm very lost.

1 Answer 1


What about using jQuery to insert the unique code to your CTA menu class or item ID? Something like:

    // generate your unique codes in jQuery
    var mycode = your_random_code_function() // or an array of codes
    // then…
    var myhref = $("body.landingpage .navbar-nav .cta a").attr("href"); 
    $("body.landingpage .navbar-nav .cta a").attr("href", myhref + "?offerid=" + mycode);
    // etc…
    // add the .cta class to the menu item that needs a code via Appearance > Menus in WP
    // or just use its WP generated ID

Otherwise I think you'd have to look at a custom walker class.

  • I would love to find a way to have it so that I can just add the offerid to a custom field of each page and it automatically generates at the end of the url
    – Bs3kg
    Commented Jul 29, 2014 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.