I've created a piece of ampscript that needs to post form data to SalesCloud. Everything works fine, however I'm not able to pass the utm parameters from this url https://cloud.e.mywebsite.com/test-form-prod?utm_source=newsletter&utm_medium=email&utm_campaign=whitepaper&utm_content=form. I'm using the following script:
SET @UTM_Source = QueryParameter('utm_source')
SET @UTM_Medium = QueryParameter('utm_medium')
SET @UTM_Campaign = QueryParameter('utm_campaign')
SET @UTM_Content = QueryParameter('utm_content')
And then in the CreateSalesforceObject the following rules (example)
SET @leadId = CreateSalesforceObject(
"Lead", 4,
"UTMSource__c", @UTM_Source,
"UTMMedium__c", @UTM_Medium,
"UTMContent__c", @UTM_Content,
"UTMCampaign__c", @UTM_Campaign)
For some reason it's not generating the parameters I have defined. Any ideas?
Thanks!
Edit: Complete code
%%[
/* form submission check */
IF RequestParameter("submitted") == true THEN
/* UTM Parameters */
SET @originId = "request-quote"
SET @UTM_Source = QueryParameter('utm_source')
SET @UTM_Medium = QueryParameter('utm_medium')
SET @UTM_Campaign = QueryParameter('utm_campaign')
SET @UTM_Content = QueryParameter('utm_content')
SET @UTM_Term = QueryParameter('utm_term')
/* check if account already exists */
SET @accountRows = RetrieveSalesforceObjects(
"Account",
"Id,Name",
"Name", "=", RequestParameter("company")
)
/* get account id if contact already exists */
IF RowCount(@accountRows) > 0 THEN
SET @accountId = Field(Row(@accountRows, 1), "Id")
ENDIF
/* set consent checkbox */
IF RequestParameter("consent") == "on" THEN
SET @consent = "true"
ELSE SET @consent = "false"
ENDIF
/* check if contact already exists */
SET @contactRows = RetrieveSalesforceObjects(
"Contact",
"Id,Email",
"Email", "=", RequestParameter("email")
)
SET @leadRows = RetrieveSalesforceObjects(
"Lead",
"Id,Email",
"Email", "=", RequestParameter("email")
)
/* get contact id if contact already exists*/
IF RowCount(@contactRows) > 0 THEN
SET @contactId = Field(Row(@contactRows, 1), "Id")
/* update contact if already exists*/
SET @updateContactRecord = UpdateSingleSalesforceObject(
"Contact", @contactId,
"FirstName", RequestParameter("firstname"),
"LastName", RequestParameter("lastname"),
"AccountId", @accountId,
"Phone", RequestParameter("phone"),
"Country__c", RequestParameter("country"),
"Industry__c", RequestParameter("industry"),
"Role_in_the_buying_process__c", RequestParameter("role"),
"CompanySize__c", RequestParameter("companysize"),
"HasOptedInForEmail__c", @consent,
"ContactOriginID__c", @originId,
"Email", RequestParameter("email")
)
/* update lead if already exists*/
ELSEIF RowCount(@leadRows) > 0 THEN
SET @leadId = Field(Row(@leadRows, 1), "Id")
SET @updateLeadRecord = UpdateSingleSalesforceObject(
"Lead", @leadId,
"FirstName", RequestParameter("firstname"),
"LastName", RequestParameter("lastname"),
"Company", RequestParameter("company"),
"Email", RequestParameter("email"),
"Phone", RequestParameter("phone"),
"Country__c", RequestParameter("country"),
"State__c", RequestParameter("state"),
"LeadIndustry__c", RequestParameter("industry"),
"RoleInTheBuyingProcess__c", RequestParameter("jobrole"),
"CompanySize__c", RequestParameter("companysize"),
"HasOptedInForEmail__c", @consent,
"LeadOriginId__c", @originId
)
/* create lead */
ELSE SET @leadId = CreateSalesforceObject(
"Lead", 16,
"FirstName", RequestParameter("firstname"),
"LastName", RequestParameter("lastname"),
"Company", RequestParameter("company"),
"Email", RequestParameter("email"),
"Phone", RequestParameter("phone"),
"Country__c", RequestParameter("country"),
"State__c", RequestParameter("state"),
"LeadIndustry__c", RequestParameter("industry"),
"RoleInTheBuyingProcess__c", RequestParameter("role"),
"CompanySize__c", RequestParameter("companysize"),
"HasOptedInForEmail__c", @consent,
"LeadOriginId__c", @originId,
"UTMSource__c", @UTM_Source,
"UTMMedium__c", @UTM_Medium,
"UTMContent__c", @UTM_Content,
"UTMCampaign__c", @UTM_Campaign
)
ENDIF
]%%
Form
<h2>Thank you for submitting the form.</h2>
%%[ ELSE ]%%
HTML form
%%[ ENDIF ]%%
I've also tried this, but no luck
"UTMSource__c", RequestParameter('utm_source'),
"UTMMedium__c", RequestParameter('utm_source'),
"UTMContent__c", RequestParameter('utm_source'),
"UTMCampaign__c", RequestParameter('utm_source')
Output(QueryParameter('utm_source'))
? That should tell you whether the problem is within the query function or later in the script