tag
Tag your URLs for Google Analytics directly in Salesforce.com
Here is a quick hack that can allow you to generate Google Analytics Tagged URL straight from a Campaign in Salesforce.com (SFDC) instead of going back and forth from SFDC and Google Analytics URL builder. More over, it allows you to standardize your tags.
Follow those 2 easy steps:
- Create a custom picklist field for each of the fields* you normally use to tag your URLs with Google URL builder.
- Create a custom formula fields that will actually build the tagged URL for you. Use the following generic formula by replacing each ___ with the SFDC field name:
“?utm_source=”+___+”&utm_medium=”+___+”&utm_term=”+___+”&utm_content=”+___+”&utm_campaign=”___
And Voilà! You now have a Tagged URL ready to be added at the end of your destination URL.
*Tag URLs allow you to use the following 5 fields (bold fields are mandatory):
- Campaign Source (utm_source)
- Campaign Medium (utm_medium)
- Campaign Term (utm_term)
- Campaign Content (utm_content)
- Campaign Name (utm_campaign)
Here is an example of how I did it for a customer:
I only used the 3 mandatory fields for Google URL tagging: Campaign Source, Campaign Medium and Campaign Name (See below screenshot).
- I used the SFDC Campaign ID as the Campaign Name (but you could also use the Campaign Name)
- I used the standard field “Type” for the Campaign Medium
- I created a custom picklist field called “Source” for the Campaign Source”Source” in which I have listed all my differents ads sources.
- I used the following formula*:
“?utm_source=”+TEXT(Source__c) +”&utm_medium=”+TEXT(Type)+”&utm_campaign=”+ Id
* Don’t forget if you use a picklist fields to add the function “TEXT” in order to get the actual picklist value.
![]() |
|


