*

Sorry, we didn't find any relevant articles for you.

Send us your queries using the form below and we will get back to you with a solution.

How do I track UTM data for successful transactions in Payments2Us Studio?

Overview

You can capture UTM parameters from a Payments2Us Studio page URL and save them on the Payment Txn record in Salesforce. This lets you report on which marketing efforts led to successful payments or donations.

Use case

You share the same donation page in an email newsletter and on social media. Each link has different UTM values. When a donor completes a payment, you can use the values on the Payment Txn record to identify which link they used.

How to Set up 

1. Create custom fields on Payment Txn

In Salesforce, go to Setup > Object Manager > Payment Txn > Fields & Relationships. Create a Text field for each UTM parameter you want to capture. Copy the API names from Salesforce so you can use the exact names in Studio and in the script. How to add custom fields on a web form

Examples of commonly used UTM parameters and their example API names:

URL parameter Salesforce field label Example API name
utm_source UTM Source utm_source__c
utm_medium UTM Medium utm_medium__c
utm_campaign UTM Campaign utm_campaign__c
utm_term UTM Term utm_term__c
utm_content UTM Content utm_content__c

2. Update field permissions for the public site

Open Public Access Settings for the Salesforce Site used by your Payments2Us checkout. Under Field-Level Security for Payment Txn, make the UTM fields visible and editable for the site profile so the checkout can save their values. Detailed instructions see: How to make a custom field visible on public web forms 

3. Add the corresponding fields to your Studio form

  1. In Studio, go to Manage Forms, select your form, then open Contact > Custom Fields.
  2. Click Add and set Field Type to Text Box.
  3. Enter a label and paste the Salesforce field’s exact API name into Parameter Key.
  4. Leave Required Field unchecked so donors can still pay when they open a link without UTM parameters.
  5. Click Save for each field, then click Update at the bottom of the form. 

How to add custom fields in Payments2Us Studio 

4. Add the UTM mapping script to your Studio page

  1. From your Studio dashboard, click the three dots beside the page that contains your form and select Update Details.
  2. Paste the script, including the <script> tags, into No Script Code. Studio inserts the code into the body of the published page. 
  3. If your Salesforce API names differ from the examples, update the values in paramAliasMap to match the Parameter Keys you configured in Studio.
  4. Click Submit to save. 
<script>
(function () {
  const params = new URLSearchParams(window.location.search);

  const paramAliasMap = {
    utm_source: "utm_source__c",
    utm_medium: "utm_medium__c",
    utm_campaign: "utm_campaign__c",
    utm_term: "utm_term__c",
    utm_content: "utm_content__c",
  };

  function setValue(el, value) {
    el.value = value;
    el.dispatchEvent(new Event("input", { bubbles: true }));
    el.dispatchEvent(new Event("change", { bubbles: true }));
  }

  function findTargetElement(paramKey) {
    let el = document.getElementById(paramKey);
    if (el) return el;

    const mappedId = paramAliasMap[paramKey];
    if (mappedId) {
      el = document.getElementById(mappedId);
      if (el) return el;
    }

    return null;
  }

  function applyParamsToMatchingIds() {
    let appliedAny = false;

    for (const [key, value] of params.entries()) {
      const el = findTargetElement(key);
      if (!el) continue;

      const tag = el.tagName.toLowerCase();
      if (!["input", "select", "textarea"].includes(tag)) continue;

      setValue(el, value);
      appliedAny = true;
    }

    return appliedAny;
  }

  function areAllPossibleParamsApplied() {
    for (const [key] of params.entries()) {
      const el = findTargetElement(key);
      if (!el) return false;
    }

    return true;
  }

  applyParamsToMatchingIds();

  const observer = new MutationObserver(() => {
    applyParamsToMatchingIds();

    if (areAllPossibleParamsApplied()) {
      observer.disconnect();
    }
  });

  observer.observe(document.documentElement, {
    childList: true,
    subtree: true,
  });
})();
</script>

5. Hide the fields and verify a successful test transaction

Return to Contact > Custom Fields in your Studio form and hide the custom fields for UTM tracking so that donors won't see them on the form.

Open your published Studio page with a test URL like the one below. Replace the example domain and page path with your own. If your URL already has a query string, add the UTM parameters with & instead of ?.

https://your-studio-domain.payments2us.com/donate?utm_source=newsletter&utm_medium=email&utm_campaign=annual_appeal&utm_term=donation&utm_content=header_button

Confirm the UTM fields are hidden, then complete a successful test payment.

Open the resulting Payment Txn in Salesforce. Verify that each configured field contains the value from the URL. For example, UTM Source should contain newsletter, and UTM Campaign should contain annual_appeal.

Need help with setup?

This article provides step-by-step instructions for setting up UTM tracking in Payments2Us Studio. If you need hands-on help with the setup, a paid Support Block is required.

 

 

Updated at November 20th, 2026

Was this article helpful?