November 2026 update — Rock v18.8

The website header scripts have been updated to support delayed rendering of Connection Opportunity Signup tracking controls. The updated script waits for the fields, sets their values, dispatches input and change events, and hides each tracking field individually. This update also adds utm_content.

Existing installations: replace both appendix scripts and add UTM Content to your attributes, fill actions, Person-writing action, and Activate Workflow mappings. Ensure all six tracking fields are included in the signup block. Existing first-touch cookies are preserved; older cookies may have no content value.

Overview

Many churches spend money on Facebook, Google Ads, email campaigns, and other marketing efforts but lose the original referral source after someone submits a form. This recipe demonstrates how to implement first-touch marketing attribution in Rock RMS.

The solution captures UTM parameters when a visitor first arrives at your website, preserves them in cookies, automatically populates tracking fields on Connection Opportunity Signup forms, and writes the original attribution to the person's record through a reusable workflow.

The original implementation was tested on Rock RMS 17.7 and used across multiple form types, including Workflow Entry forms, Connection Requests, and Prayer Requests. The updated header scripts below support delayed rendering of tracking controls for the v18.8 implementation.

This was developed at Prairie Lakes Church and is shared with the Rock Community as a reusable foundation for first-touch marketing attribution.

What You'll End Up With

After completing this recipe, your Rock instance will:

  • Capture utm_source.
  • Capture utm_medium.
  • Capture utm_campaign.
  • Capture utm_content.
  • Record the first captured touch date.
  • Record a form date when attribution is written to the Person.
  • Preserve the visitor's original captured source.
  • Populate and hide Connection Request tracking fields.
  • Write attribution to eligible Person records.
  • Prevent existing Person attribution from being overwritten.
  • Reuse the same attribution workflow across multiple forms.

Architecture

  1. A visitor arrives using a campaign link.
  2. The header script detects UTM parameters.
  3. First-touch cookies are created.
  4. A Connection Request or workflow-based form receives the attribution.
  5. The form or feeder activates the Marketing Attribution workflow.
  6. The workflow writes attribution to an eligible Person record.

This recipe assumes you're comfortable with:

  • Rock workflows
  • Person Attributes
  • JavaScript
  • Lava
  • Website configuration
  • Workflow Entry or Form Builder

Step 1 – Create Person Attributes

Create the following Person attributes in a category called UTM:

Name Key
First SourceFirstSource
First MediumFirstMedium
First CampaignFirstCampaign
First ContentFirstContent
First Touch DateFirstTouchDate
First Form DateFirstFormDate

First Source, First Medium, First Campaign, and First Content use Text. The Person date attributes may use Date or Text; choose consistently with your workflow values and reporting needs.

Person attribute configuration

UTM Person attributes

Step 2 – Install the Global UTM Capture Script

Go to Websites → your website → Edit → Advanced Settings → Page Header Content.

Install Appendix A followed by Appendix B inside one <script> element. Adding the functions here allows attribution cookies to be captured across pages using that website configuration.

If updating an existing installation, replace the old functions rather than adding duplicates.

The scripts do not require jQuery or a Meta Pixel. Any existing Meta Pixel setup is separate.

This step contains two functions:

  1. Capture and preserve first-touch cookies globally.
  2. Populate and hide Connection Request tracking controls when all six expected fields are present.

The first function supports the whole attribution system. The second applies to Connection Opportunity Signup forms and does not require a surrounding Tracking fieldset.

Prepare campaign links containing UTM parameters for testing. A campaign tagging spreadsheet can help you keep parameter names and values consistent.

Step 2A – Capture First-Touch UTM Values

The first function:

  • Reads utm_source, utm_medium, utm_campaign, and utm_content.
  • Stores attribution in a first_touch JSON cookie.
  • Creates individual cookies for Lava workflow actions.
  • Preserves an existing first_touch cookie.
  • Does not establish attribution when utm_content is the only UTM value supplied.

See Appendix A for the script.

Step 2B – Populate Connection Request Tracking Fields

This function finds tracking controls by their exact displayed labels. It waits up to 15 seconds for delayed rendering, populates the controls from first-touch cookies, dispatches input and change events, and hides each individual form-group wrapper.

All six labels must match exactly:

  • UTM Source
  • UTM Medium
  • UTM Campaign
  • UTM Content
  • First Touch Date
  • First Form Date

If any control is missing, the function waits instead of partially populating the form. Ensure all six attributes are included in the signup block.

The script also hides a separate heading named Tracking or UTM Tracking.

Workflow-based forms can continue reading cookies directly with Lava, as described later.

See Appendix B for the script.

Cookie Notice

This implementation stores first-touch marketing attribution in first-party browser cookies for up to 365 days. Review your organization's privacy policy and consent requirements before deploying it.

Adjust the cookie lifetime by changing the expiration values in Appendix A.

Step 3 – Create Connection Request Tracking Attributes

Name Key Type Category
UTM SourceUTMSourceTextUTM Tracking
UTM MediumUTMMediumTextUTM Tracking
UTM CampaignUTMCampaignTextUTM Tracking
UTM ContentUTMContentTextUTM Tracking
First Touch DateFirstTouchDateTextUTM Tracking
First Form DateFirstFormDateTextUTM Tracking

Go to Settings → Attribute Categories → Add.

Name the category UTM Tracking and set its entity type to Connection Request. An existing category named Tracking can also be used.

Connection Request attribute category

Next, go to Entity Attributes. Add each attribute with the entity type set to Connection Request.

Leave the qualifier field and qualifier value blank if the attributes should be available across Connection Types. Assign each attribute to the tracking category.

Connection Request entity attribute configuration

Use Text for the workflow and Connection Request tracking attributes because they receive string values from cookies and Lava. The final Person date attributes may use Date or Text.

Step 4 – Choose an Implementation Path

Create a Text workflow attribute named UTM Content, key UTMContent, in each applicable form and both attribution workflows. Include UTMContent in every Activate Workflow mapping that passes attribution to the central workflow.

Older screenshots below may show only Source, Medium, and Campaign. Include Content as documented in the updated instructions.

Option A – Connection Opportunity Signup

This path passes Connection Request attributes through the UTM Attribution Feeder into the Marketing Attribution workflow.

  1. Include the UTM Tracking category, or your existing Tracking category, in the signup block configuration.
  2. Ensure all six tracking attributes render as text controls with the exact labels listed in Step 2B.
  3. Attach the feeder workflow to the applicable Connection Type.
  4. Launch the feeder when the request starts.
  5. Pass the Person and all six tracking values into the central workflow.

Open a page using the Connection Opportunity Signup block and edit its block settings. Include the tracking attribute category. The selected Connection Opportunity will depend on the form.

Connection Opportunity Signup block settings

See Steps 5 and 6 for the workflows that write these values to the Person record.

Option B – Rock Form That Creates or Identifies a Person

Add these workflow attributes:

  • Person
  • First Name
  • Last Name
  • Email
  • Phone, if applicable
  • UTM Source — UTMSource
  • UTM Medium — UTMMedium
  • UTM Campaign — UTMCampaign
  • UTM Content — UTMContent
  • First Touch Date — FirstTouchDate
  • First Form Date — FirstFormDate

Add actions in this order:

  1. Set or create the Person using the submitted identifying fields.
  2. Fill UTM Source using Attribute Set Value.
  3. Fill UTM Medium using Attribute Set Value.
  4. Fill UTM Campaign using Attribute Set Value.
  5. Fill UTM Content using Attribute Set Value.
  6. Fill First Touch Date using Attribute Set Value.
  7. Fill First Form Date using Attribute Set Value.
  8. Activate the Marketing Attribution workflow and map the Person, four UTM attributes, and two date attributes.

Use the corresponding Lava in each Attribute Set Value action:

AttributeText Value
UTM Source{{ 'utm_source' | ReadCookie }}
UTM Medium{{ 'utm_medium' | ReadCookie }}
UTM Campaign{{ 'utm_campaign' | ReadCookie }}
UTM Content{{ 'utm_content' | ReadCookie }}
First Touch Date{{ 'first_touch_date' | ReadCookie }}
First Form Date{{ 'Now' | Date:'yyyy-MM-dd' }}

Form workflow actions

The example includes attribution actions alongside actions used by the form itself. Add a separate Fill UTM Content action.

Attribute Set Value action

An example Attribute Set Value action.

Activate Marketing Attribution workflow

Map the attribution values into the central workflow. Include UTMContent in addition to the values shown in older screenshots.

Option C – Rock Form That Creates Another Entity

Use this path for forms such as Prayer Request Entry.

Add the same workflow attributes described in Option B.

Before setting or creating the Person, populate the identifying fields from the entity using Attribute Set From Entity actions:

  • Fill First Name From Entity
  • Fill Last Name From Entity
  • Fill Email From Entity
  • Fill Phone Number From Entity, if available

Set Entity Required to Yes and Use Id Instead of Guid to No. For the applicable entity, use the corresponding Lava:

{{ Entity.FirstName }}
{{ Entity.LastName }}
{{ Entity.Email }}
{{ Entity.PhoneNumber }}

Then add the remaining actions from Option B, including setting the Person, reading all four UTM cookies, setting the dates, and activating the central workflow.

Step 5 – Set Up UTM/Marketing Attribution Workflow

Create these workflow attributes:

  • Person — Person field type
  • UTM Source — UTMSource — Text
  • UTM Medium — UTMMedium — Text
  • UTM Campaign — UTMCampaign — Text
  • UTM Content — UTMContent — Text
  • First Touch Date — FirstTouchDate — Date
  • First Form Date — FirstFormDate — Date
  • Can Update Attribution — CanUpdateAttribution — Text

First, add an Attribute Set Value action targeting Can Update Attribution. Use this Lava:

{%- assign person = Workflow | Attribute:'Person','Object' -%}

{%- assign createdDate = person.CreatedDateTime | Date:'yyyyMMdd' -%}
{%- assign cutoffDate = 'Now' | DateAdd:'-60','d' | Date:'yyyyMMdd' -%}

{%- assign existingSource = person | Attribute:'FirstSource' -%}
{%- assign existingMedium = person | Attribute:'FirstMedium' -%}
{%- assign existingCampaign = person | Attribute:'FirstCampaign' -%}
{%- assign existingContent = person | Attribute:'FirstContent' -%}

{%- if person
    and createdDate >= cutoffDate
    and existingSource == empty
    and existingMedium == empty
    and existingCampaign == empty
    and existingContent == empty
-%}
    True
{%- else -%}
    False
{%- endif -%}

This checks that a Person was provided, that the Person record was created within the last 60 days, and that First Source, First Medium, First Campaign, and First Content are empty.

The 60-day cutoff is an organizational choice and can be adjusted. Content does not change this eligibility rule.

For each remaining action, configure the run filter as Can Update Attribution Equal To the text value True.

Add Person Attribute Set actions with Person set to the workflow's Person attribute:

Incoming Workflow AttributePerson Attribute
UTM SourceFirst Source
UTM MediumFirst Medium
UTM CampaignFirst Campaign
UTM ContentFirst Content
First Touch DateFirst Touch Date
First Form DateFirst Form Date

For each action, select the corresponding Person attribute and supply the matching incoming workflow value.

Marketing Attribution workflow actions

Person Attribute Set configuration

Step 6 – Set Up UTM Attribution Feeder Workflow

The feeder reads attribution from a Connection Request and passes it into the Marketing Attribution workflow.

Create the same attributes as Step 5, except Can Update Attribution.

First, add a Set Person action:

  • Action type: Attribute Set From Entity
  • Target attribute: Person
  • Entity Required: Yes
  • Use Id Instead of Guid: No
  • Lava: {{ Entity.PersonAlias.Guid }}

Feeder Set Person action

Next, add a separate Attribute Set From Entity action for each tracking value. Set Entity Required to Yes and Use Id Instead of Guid to No.

Target Workflow AttributeLava
UTM Source{{ Entity | Attribute:'UTMSource' }}
UTM Medium{{ Entity | Attribute:'UTMMedium' }}
UTM Campaign{{ Entity | Attribute:'UTMCampaign' }}
UTM Content{{ Entity | Attribute:'UTMContent' }}
First Touch Date{{ Entity | Attribute:'FirstTouchDate' | Date:'yyyy-MM-dd' }}
First Form Date{{ Entity | Attribute:'FirstFormDate' | Date:'yyyy-MM-dd' }}

Finally, add an Activate Workflow action targeting UTM/Marketing Attribution. Map the Person, all four UTM values, and both dates into their corresponding target attributes.

Attaching This Workflow

Go to Connections → Connection Types → select the Connection Type → Edit → Workflows → Add.

  • Launch Workflow When: Request Started
  • Workflow Type: UTM Attribution Feeder

Attach feeder to Connection Type

Step 7 – Testing

Start in a fresh private browsing session and visit a test link containing all four UTM parameters:

https://YOUR-WEBSITE/your-form?utm_source=test&utm_medium=email&utm_campaign=v188-test&utm_content=button-a

Use a new test Person eligible under the workflow's 60-day rule.

Browser Verification

Confirm that these cookies are created:

  • first_touch
  • utm_source
  • utm_medium
  • utm_campaign
  • utm_content
  • first_touch_date

Connection Request Form Verification

  • All six tracking fields are included in the signup block.
  • The tracking controls disappear after rendering.
  • The Tracking or UTM Tracking heading is hidden.
  • The submitted Connection Request contains the expected UTM values and dates.

Workflow-Based Form Verification

  • Identifying fields populate correctly.
  • The correct Person is identified or created.
  • All four UTM values populate from cookies.
  • Both date values populate.

Workflow Verification

  • The Marketing Attribution workflow runs successfully.
  • The workflow receives the correct Person.
  • The workflow receives all four UTM values.
  • The workflow receives both dates.
  • Can Update Attribution returns the expected result.

Person Record Verification

Verify the eligible Person record contains:

  • First Source
  • First Medium
  • First Campaign
  • First Content
  • First Touch Date
  • First Form Date

Regression Test

Visit a different campaign URL in the same browser session and submit another form for the same individual.

  • The original first-touch cookies remain unchanged.
  • The original Person attribution remains unchanged.

For Connection Requests, the header script sets First Form Date when it populates the form, using the UTC date. Workflow-based forms use the date supplied by their Lava action. The central workflow controls whether the value is saved to the Person.

Quality Control Checklist

  • All required Person, workflow, and Connection Request attributes exist.
  • The global JavaScript is installed once.
  • Browser cookies are created successfully.
  • All six tracking labels match Appendix B exactly.
  • Form actions run in the correct order.
  • Entity-based forms populate identifying fields before the Set Person action runs.
  • The Set Person action identifies the correct individual.
  • UTMContent is included in all applicable workflow mappings.
  • The Person-writing actions target the correct attributes.
  • Existing first-touch attribution remains unchanged.

Final Result

A visitor arrives from a campaign, the browser preserves the first captured attribution, and supported forms pass that attribution to the central workflow. Eligible Person records receive the values for reporting.

Below is an example of the UTM attributes on a test Person record:

Person attribution values

Downloads

After importing: open the feeder’s Activate Workflow action and select your imported Marketing Attribution workflow. Verify its attribute mappings. In the Marketing Attribution workflow, select your own Person attributes in each Person Attribute Set action.

Appendix

Copy the rendered JavaScript from Appendix A followed by Appendix B into a <script> element in your website's Page Header Content.

Appendix A – Capture First-Touch UTM Values

(function () {
    const params = new URLSearchParams(window.location.search);
    const source = params.get('utm_source');
    const medium = params.get('utm_medium');
    const campaign = params.get('utm_campaign');
    const content = params.get('utm_content');

    function setCookie(name, value, days) {
        const expires = new Date(
            Date.now() + days * 86400000
        ).toUTCString();

        document.cookie =
            name + '=' + encodeURIComponent(value) +
            '; expires=' + expires +
            '; path=/' +
            '; SameSite=Lax';
    }

    function getCookie(name) {
        return document.cookie
            .split('; ')
            .find(row => row.startsWith(name + '='));
    }

    /*
     * Preserve only the original first touch.
     * Content alone does not establish attribution.
     */
    if (
        (source || medium || campaign) &&
        !getCookie('first_touch')
    ) {
        const firstTouch = {
            source: source || '',
            medium: medium || '',
            campaign: campaign || '',
            content: content || '',
            capturedDate: new Date().toISOString()
        };

        const firstTouchJson = JSON.stringify(firstTouch);

        setCookie('first_touch', firstTouchJson, 365);
        setCookie('utm_source', firstTouch.source, 365);
        setCookie('utm_medium', firstTouch.medium, 365);
        setCookie('utm_campaign', firstTouch.campaign, 365);
        setCookie('utm_content', firstTouch.content, 365);
        setCookie(
            'first_touch_date',
            firstTouch.capturedDate.split('T')[0],
            365
        );
    }
})();

Appendix B – Populate and Hide Connection Request Tracking Fields

(function () {
    function getCookie(name) {
        const value = '; ' + document.cookie;
        const parts = value.split('; ' + name + '=');

        if (parts.length === 2) {
            return decodeURIComponent(
                parts.pop().split(';').shift()
            );
        }

        return '';
    }

    function setControlValue(control, value) {
        if (!control || !value) {
            return;
        }

        const prototype = Object.getPrototypeOf(control);

        const valueSetter =
            Object.getOwnPropertyDescriptor(
                prototype,
                'value'
            )?.set;

        if (valueSetter) {
            valueSetter.call(control, value);
        } else {
            control.value = value;
        }

        control.dispatchEvent(
            new Event('input', {
                bubbles: true
            })
        );

        control.dispatchEvent(
            new Event('change', {
                bubbles: true
            })
        );
    }

    function populateTrackingFields() {
        const expectedLabels = [
            'UTM Source',
            'UTM Medium',
            'UTM Campaign',
            'UTM Content',
            'First Touch Date',
            'First Form Date'
        ];

        const allLabels = [
            ...document.querySelectorAll('label')
        ];

        const controls = {};

        /*
         * Wait until all six tracking controls have rendered.
         */
        for (const labelText of expectedLabels) {
            const label = allLabels.find(element =>
                element.textContent.trim() === labelText
            );

            if (!label) {
                return false;
            }

            const control =
                (
                    label.htmlFor
                        ? document.getElementById(label.htmlFor)
                        : null
                ) ||
                label
                    .closest('.form-group')
                    ?.querySelector(
                        'input, textarea, select'
                    );

            if (!control) {
                return false;
            }

            controls[labelText] = {
                label,
                control
            };
        }

        const firstTouchRaw = getCookie('first_touch');
        let firstTouch = {};

        try {
            firstTouch = firstTouchRaw
                ? JSON.parse(firstTouchRaw) || {}
                : {};
        } catch (error) {
            console.warn(
                'Could not parse first_touch cookie',
                error
            );
        }

        const firstTouchDate = (
            firstTouch.capturedDate ||
            getCookie('first_touch_date') ||
            ''
        ).split('T')[0];

        const values = {
            'UTM Source':
                firstTouch.source ||
                getCookie('utm_source'),

            'UTM Medium':
                firstTouch.medium ||
                getCookie('utm_medium'),

            'UTM Campaign':
                firstTouch.campaign ||
                getCookie('utm_campaign'),

            'UTM Content':
                firstTouch.content ||
                getCookie('utm_content'),

            'First Touch Date':
                firstTouchDate,

            'First Form Date':
                new Date()
                    .toISOString()
                    .split('T')[0]
        };

        Object.entries(values).forEach(
            ([labelText, value]) => {
                const item = controls[labelText];

                setControlValue(
                    item.control,
                    value
                );

                const wrapper =
                    item.label.closest('.form-group');

                if (wrapper) {
                    wrapper.style.setProperty(
                        'display',
                        'none',
                        'important'
                    );
                }
            }
        );

        document.querySelectorAll('h4').forEach(
            heading => {
                const headingText =
                    heading.textContent.trim();

                if (
                    headingText === 'Tracking' ||
                    headingText === 'UTM Tracking'
                ) {
                    heading.style.setProperty(
                        'display',
                        'none',
                        'important'
                    );
                }
            }
        );

        return true;
    }

    /*
     * Support controls that have already rendered.
     */
    if (populateTrackingFields()) {
        return;
    }

    /*
     * Wait for delayed rendering.
     */
    const observer = new MutationObserver(function () {
        if (populateTrackingFields()) {
            observer.disconnect();
        }
    });

    /*
     * Page Header scripts can run before body exists.
     */
    observer.observe(
        document.documentElement,
        {
            childList: true,
            subtree: true
        }
    );

    /*
     * Avoid observing indefinitely.
     */
    setTimeout(function () {
        observer.disconnect();
    }, 15000);
})();