A client asked if there were a way to set the
tracking_code field in a new
supporter_action record. There's not a way to do that in Salsa automatically, but it can be done with a bit of SalsaScript.
Difficulty: +5 (Programming experience required.)
This is a fairly complex solution that is only used in a situation where you're able to report on the contents of the
supporter_action table. If that is not what you are doing, then this article is not for you.
Use these steps to install the solution.
- Edit the template used by the action that you want to use to track
- Use the browser's search too to locate the </head> tag.
- Insert a blank line just before the </head> tag.
- Click here to see the page where the solution lives.
- Click the
Rawbutton. A window will appear that contains only the solution.
- Copy the contents of the window and close it.
- Return to the template editor.
- Paste the copied text into the newly inserted line in the template.
- Save the template.
- Leave the template editor open for the next step.
List of valid keys
The first configurable item is the list of thank you page keys (https://screencast.com/t/m8kHgKjso). The variable contains a comma-separated list of keys.
If the script is going to be used on one and only one thank you page, then the only change to to replace 547 with the thank you page of interest. If the script is going to work on more than one thank you page, then replace 547 with a comma-separated list of thank you page keys (no spaces, please). For example, to use the script on thank you pages with keys 123, 124, and 125, then the modified line would look like this:
var validKeys = '123,124,125'.split(',');
The second configurable item is the URL query/parameter for the thank you page. Currently, this script works only with thank you pages. If you'd like to use, say, Tell-A-Friend pages, then the configuration line needs to specify a Tell-A-Friend key:
var pageKey = Request.getParameter('tell_a_friend_KEY');
Note that changing the
pageKey to use Tell-A-Friend pages means that the the list of keys (above) must be a list of valid Tell-A-Friend keys.
Here are a couple of use cases that you might find helpful.
Provide a tracking code in the action URL
In this case, the tracking code appears in the action URL. This is a great way to attribute actions-taken to partners or to where the action appears in a page or email. There are two parts to this use case.
The first part is to configure the redirect for the action to pass a tracking code to the thank you page. Here's an example (URL on separate lines to improve readability):
The second part is to accept a tracking_code in the action URL. Here's an example:
Salsa will fill in the supporter_action_KEY parameter with the primary key of the newly created supporter_action record. The tracking code will be filled with 'partner_1'. That's all that the solution needs to do its work.
Hard code a tracking code
In this use case, the tracking code is static for all supporters that take the action. For example, to pass "SupportedPizzaTrain" as a tracking tracking code, the action needs to redirect to this thank you page URL:
As in the previous use case, the solution is provided the two parameters that it needs.
If you have any questions, then please gather this information
chapter KEYif you are in a chapter of another organization
template_KEYof the modified template
- The URL of a page that uses the modified template
- A screenshot
Send this information to email@example.com, and we'll be glad to help.