Get URL Parameters via JavaScript on a Marketo Landing Page

Version 1

    On your Marketo landing pages, if you want to retrieve a URL parameter via Javascript, here's how to do it.

    First, identify the URL parameters you want to capture. We'll use Google search parameters -- "utm_keyword" "utm_campaign" "utm_term" and "__kk".

    Please ensure that you have access to an experienced JavaScript developer.

     

     

    Marketo Technical Support is not set up to assist with troubleshooting JavaScript.

    Below is the Javascript you'll need.  Add this to your landing page with a Custom HTML element or by editing a landing page template:

    <script language="Javascript" src="/js/public/jquery-latest.min.js" type="text/javascript"></script>
    <script src="/js/public/jQueryString-2.0.2-Min.js" type="text/javascript" ></script>
    <script>
      // to set cookies.  Uses noConflict just in case
      var $jQ = jQuery.noConflict();
      var utm_keyword = $jQ.getQueryString({ ID: "utm_keyword" });
      var utm_source = $jQ.getQueryString({ ID: "utm_source" });
      var utm_term = $jQ.getQueryString({ ID: "utm_term" });
      var __kk = $jQ.getQueryString({ ID: "__kk" });
    </script>