Skip to content

Instantly share code, notes, and snippets.

@MyCueCards
Created February 13, 2019 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MyCueCards/e72bfbacdc4e6d8405cf9b137a701ecf to your computer and use it in GitHub Desktop.
Save MyCueCards/e72bfbacdc4e6d8405cf9b137a701ecf to your computer and use it in GitHub Desktop.
In Salesforce Marketing Cloud, a client is using AMPscript to pull a URL from the sending data extension (DE) into an email. The client has a Web Analytics Connector (WAC) integration, which adds parameters to the end of a URL when the email recipient opens the email. The URL generated from the WAC attempts to use a value from the sending DE, wh…
<!-- AMPscript Block -->
%%[
var @UTMstring1
set @UTMstring1 = "?utm_source=SFMC&utm_medium=email&utm_campaign"
var @UTMstring2
set @UTMstring2 = "&utm_content="
var @UTMstring3
set @UTMstring3 = "&utm_subscriber="
var @url1
set @url1 = ProductUrl1
var @link1
set @link1 = Concat('href="',@url1,@UTMstring1,emailname_,@UTMstring2,@url1,@UTMstring3,subscriberid,'"')
set @link1 = URLEncode(@link1)
]%%
<!-- snippets within HTML -->
This is the URL: <a %%=v(@link1)=%% target="_blank">%%ProductUrl1%%</a>
@enriquediazmorales
Copy link

enriquediazmorales commented Jan 23, 2020

Hi Harely, First of all, Thanks a lot for your contribution. Much appreciated. I have been using your solution here explained to face the same issue I had and is working perfectly but applying this solution my people from GA told me that clicks are not being registered in GA. Applying your solution here I can see that the click.info.xxx tracking link is not being created in MC. Could be this the problem for not tracking the clicks in GA ? Thanks in advance. Best

@MyCueCards
Copy link
Author

If I recall, SFMC may not track the clicks, since the click.domain.com wrapper no longer exists. That may be what you're describing. When this was written, it was just to get the URL parameters from a webpage to GA. If you have a setup where email clicks are being tracked by SFMC and then fed into GA, then this code won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment