Answers.Body: <p>It looks like you're not using the jQuery snippet mentioned <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL" rel="nofollow">here</a> to populate your hidden values.</p>
  
  <p>Also, there's a Google Summer of Code 2015 project that will hopefully make this question obsolete: Also, this may not be ready in time for you, but some of what you want is coming to core: forum.civicrm.org/index.php?topic=36091.0 </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-18T23:15:20.910Z
Answers.LastActivityDate: 2015-06-18T23:15:20.910Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>Drupal 7.37, CiviCRM 4.4.15</p>
  
  <p>Principles outlined in this <strong><a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL" rel="nofollow">page</a></strong> to embed a variable in the URL that gets stored in a hidden field on the contribution page.</p>
  
  <p>Do I need to make the custom fields required or read-only? I made them searchable.  For each contribution I am getting a row inserted into the database table "civicrm_value_campaign_1", but the three fields are all blank.</p>
  
  <p>URL: www.domain.org/civicrm/contribute/transact?reset=1&amp;id=8&amp;custom_1=sponsorship&amp;custom_2=15&amp;custom_3=child&amp;amount=35.00</p>
  
  <pre><code>&lt;?php
  
  function pptsponsorship_civicrm_buildForm($formName, &amp;$form)
  {
  // enable tracking feature
  if (($formName == 'CRM_Contribute_Form_Contribution_Main' ||
          $formName == 'CRM_Contribute_Form_Contribution_Confirm' ||
          $formName == 'CRM_Contribute_Form_Contribution_ThankYou') &amp;&amp;
      $form-&gt;getVar('_id') == 8 ) { // use  CONTRIBUTION PAGE ID here
  
      // use the custom field ID and custom field label here
      $trackingFields = array('custom_1' =&gt; 'Campaign',
          'custom_2' =&gt; 'Appeal',
          'custom_3' =&gt; 'Fund');
      $form-&gt;assign('trackingFields', $trackingFields);
  
      if ($_GET['amount']) {
          $defaults['price_3'] = $_GET['amount']; //set the other value
          $defaults['frequency_interval'] = 1;
      }
      $form-&gt;setDefaults($defaults);
  }
  }  
  </code></pre>
  
  <p>changed the code to the following:</p>
  
  <p>
  
  <p>function pptsponsorship_civicrm_buildForm($formName, &amp;$form)
  {
      // enable tracking feature
      if (($formName == 'CRM_Contribute_Form_Contribution_Main' ||
              $formName == 'CRM_Contribute_Form_Contribution_Confirm' ||
              $formName == 'CRM_Contribute_Form_Contribution_ThankYou') &amp;&amp;
          $form->getVar('_id') == 8 ) { // use  CONTRIBUTION PAGE ID here</p>
  
  <pre><code>    if (!$_GET['custom_1']) {
          require_once 'CRM/Core/BAO/CustomGroup.php';
          $defaults = CRM_Core_BAO_CustomGroup::extractGetParams( $this, "'Contact', 'Individual', 'Contribution'" );
      } else {
          $defaults['custom_1'] = $_GET['custom_1'];
          $defaults['custom_2'] = $_GET['custom_2'];
          $defaults['custom_3'] = $_GET['custom_3'];
      }
  
      // use the custom field ID and custom field label here
      $trackingFields = array('custom_1' =&gt; 'Campaign:Campaign',
          'custom_2' =&gt; 'Campaign:Appeal',
          'custom_3' =&gt; 'Campaign:Fund');
      $form-&gt;assign('trackingFields', $trackingFields);
  
      if ($_GET['amount']) {
          $defaults['price_3'] = $_GET['amount'];
          $defaults['frequency_interval'] = 1;
      }
      $form-&gt;setDefaults($defaults);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It is now working.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-18T03:19:53.917Z
Comments.Text: How are you populating your hidden fields?  Are you using a jQuery snippet like the one linked to from the page you mentioned?  If so, please update your question with that code.  Also, this may not be ready in time for you, but some of what you want is coming to core: http://forum.civicrm.org/index.php?topic=36091.0
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-18T22:49:30.980Z
Comments.Text: Missed that small step at the beginning.  Thank you
Comments.UserDisplayName: mike_kc
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-18T23:14:03.440Z
Comments.Text: Glad that helped.  I'm going to leave that as an answer, so as not to leave a question in the "unanswered" queue.
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <civicontribute><drupal>
Title: Not sure that I have Contribution Tracker configured correctly
ThreadText: # Not sure that I have Contribution Tracker configured correctly
  
  (Asked by: username_0 on 2015-06-17)
  
  Drupal 7.37, CiviCRM 4.4.15
  Principles outlined in this page to embed a variable in the URL that gets stored in a hidden field on the contribution page.
  Do I need to make the custom fields required or read-only? I made them searchable.  For each contribution I am getting a row inserted into the database table "civicrm_value_campaign_1", but the three fields are all blank.
  URL: www.domain.org/civicrm/contribute/transact?reset=1&id=8&custom_1=sponsorship&custom_2=15&custom_3=child&amount=35.00
  getVar('_id') == 8 ) { // use  CONTRIBUTION PAGE ID here
  
      // use the custom field ID and custom field label here
      $trackingFields = array('custom_1' => 'Campaign',
          'custom_2' => 'Appeal',
          'custom_3' => 'Fund');
      $form->assign('trackingFields', $trackingFields);
  
      if ($_GET['amount']) {
          $defaults['price_3'] = $_GET['amount']; //set the other value
          $defaults['frequency_interval'] = 1;
      }
      $form->setDefaults($defaults);
  }
  }  
  
  changed the code to the following:
  
  function pptsponsorship_civicrm_buildForm($formName, &$form)
  {
      // enable tracking feature
      if (($formName == 'CRM_Contribute_Form_Contribution_Main' ||
              $formName == 'CRM_Contribute_Form_Contribution_Confirm' ||
              $formName == 'CRM_Contribute_Form_Contribution_ThankYou') &&
          $form->getVar('_id') == 8 ) { // use  CONTRIBUTION PAGE ID here
      if (!$_GET['custom_1']) {
          require_once 'CRM/Core/BAO/CustomGroup.php';
          $defaults = CRM_Core_BAO_CustomGroup::extractGetParams( $this, "'Contact', 'Individual', 'Contribution'" );
      } else {
          $defaults['custom_1'] = $_GET['custom_1'];
          $defaults['custom_2'] = $_GET['custom_2'];
          $defaults['custom_3'] = $_GET['custom_3'];
      }
  
      // use the custom field ID and custom field label here
      $trackingFields = array('custom_1' => 'Campaign:Campaign',
          'custom_2' => 'Campaign:Appeal',
          'custom_3' => 'Campaign:Fund');
      $form->assign('trackingFields', $trackingFields);
  
      if ($_GET['amount']) {
          $defaults['price_3'] = $_GET['amount'];
          $defaults['frequency_interval'] = 1;
      }
      $form->setDefaults($defaults);
  }
  
  }
  It is now working.
  
  **Tags:** civicontribute, drupal
  
  > **Comments:**
  > **username_1**: How are you populating your hidden fields?  Are you using a jQuery snippet like the one linked to from the page you mentioned?  If so, please update your question with that code.  Also, this may not be ready in time for you, but some of what you want is coming to core: http://forum.civicrm.org/index.php?topic=36091.0  
  > **username_0**: Missed that small step at the beginning.  Thank you  
  > **username_1**: Glad that helped.  I'm going to leave that as an answer, so as not to leave a question in the "unanswered" queue.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-18. Score: 1
  
  It looks like you're not using the jQuery snippet mentioned [here](http://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL) to populate your hidden values.
  
  Also, there's a Google Summer of Code 2015 project that will hopefully make this question obsolete: Also, this may not be ready in time for you, but some of what you want is coming to core: forum.civicrm.org/index.php?topic=36091.0
  
  
  ---
  
  