Skip to main content

Return to TX Community

Liaison

Tracking UTM (Google Analytics) Conversions for Reporting

 These steps are intended to be followed by an individual who is accustomed to writing apex code, visualforce code, html, understands querystring parameters, and can create customer fields. These instructions are intended to be followed in a sandbox environment before being pushed to production via Outbound Change Set.

Overview

The steps below outline how you can enhance your standard signup form by recording tracking codes that identify acquisition sources. This example is based around using the popular tool Google Analytics, which uses the following query string values utm_campaign, utm_source, utm_medium, etc.

These values are provided to a landing page by querystring. Note the following screenshot showing that I landed on the following page by clicking an ad from a site and that site provided utm_ codes in the URL:

 

discover.ecpi.edu/nurs/index.php?utm_source=campusexpclick$&utm_medium=cpc&utm_campaign

Sample landing page

Add your tracking fields to the Contact record

  1. Click Setup
  2. Type Contact into the left nav search Field.
  3. Click Fields under the Contact  navigation:

Contact fields window

  1. Click the New button at the top of the “Contact Custom Fields & Relationships” section.
  2. Choose a type =  text.
  3. Choose a logical name for your use case; in this example, it’s called “UTM Campaign”:

Note the “Field Name” for later.
New Custom Field window

  1. Click Next then Save to finish the wizard.

Open the visualforce page controller (class)


This step will copy the value from the URL when the user is signing up (the query string) to the Contact record for reporting. During user signup within a Salesforce Customer Community, a User record is created and also a Contact record (Note:  If public access settings allow it when email matches with an existing user, the related Contact record is updated). At the point where the Contact is created, we will copy the tracking value to the Contact record’s new custom field we created before.

  1. Click Setup
  2. Type “class” into the left nav search Field
  3. Click “Apex Classes

Apex Classes window

  1. Filter/sort/paginate the table to find the row with Name “TX_CommunitiesSelfRegController”
  2. Click “Edit” on the row with the Name “”

Select TX_CommunitiesSelfRegController option from list

Map the query string parameter to your custom field to save the value

  1.  Locate the following:  

String userId = Site.createPortalUser(u, String.isBlank(accountId) ? null : accountId, password);

 if (userId != null) {

  • Add a new line and enter the following:

update new Contact(
    Id=[select ContactId from User where Id = :userId].ContactId,
    UTM_Campaign__c=ApexPages.currentPage().getParameters().get('utm_campaign')
);

query string parameter

Please note:  The field “UTM_Campaign__c” in the sample below should be changed to the API name of the tracking field you created.

  1. Save your changes.

Reporting

To report on which applications came from students that were acquired through given UTM Campaign values, create a new report:

  1. Open the “Reports” tab
  2. Click the “New” button
  3. Select the “Contacts with Applications” report type and click “Create”

Create new report window


Group by the “UTM Campaign” field to see the number of applications that came from given UTM Campaign values:


Contacts with Applications report
Additional groupings can illuminate which acquisition sources have more effective close completion rates:
Bar graph



See also Setting up Google Analytics for TargetX products
 

  • Was this article helpful?