emaildevComments Off on SalesForce Marketing Cloud “Subject Prefix” issue
If your subject line starts with a variable or any AMPscript (ex: %%FIRST_NAME%%), your “Subject Prefix” need a space at the end of it, or any character if your prefix is enclosed in brackets like this –> [ ]. It looks for the closing bracket and expects a space after. If it doesn’t have the space, or any character, it looks like it removes the first %% characters from the subject line code, and the AMPscript does not render, showing broken code in the inbox.
You can add a space, a colon, or even the opening bracket character, and the code won’t break, but it treats the closing bracket differently.
To ensure that your email campaigns function as intended as we make these changes, we’ve introduced a new AMPscript string. Append this string to the end of your subject line to enforce single resolve:
Problem: Email previews fine in SFMC , but will not send. No errors. No clue as to the issue.
The problem: href=”httpgetwrap|%%=RedirectTo(‘https://blahblahblah.com‘)=%%” The fix: href=”httpgetwrap|https://blahblahblah.com“
The problem was some code in an external block of content that was being pulled into the email via httpget, where the link URLs were not formatted correctly.
The RedirectTo() function is only needed when using a variable for a URL in an HREF. Not only is it not needed, but this was stopping the email from sending. There were no errors during preview, so it was really difficult to find the issue. My IDE (Dreamweaver) did not show it as any kind of error either, so it took a lot of trial and error to find the bad code. The email had a lot of dynamic content, and after removing all the dynamic content, and then replacing blocks one-by-one did I narrow it down to the block that was culprit. Even then, finding the issue in that block too a little while.
The Problem: Email does not preview in SFMC , nor will it send. No errors. No clue as to the issue.
The issue was a hidden special character in the data. A data field was being used to match a name of a content block on AWS. Even though the characters was hidden, it was still creating mismatch.
The fix: I was able to see the hidden character in Dreamweaver’s code view. It appeared as red dot. The character was removed from the data it worked. You could use AMPscript to look for the character using IndexOf(), and use Replace() to get ride of it, but that can be cumbersome when you have an email with a lot of content pull from the data in many different fields.
emaildevComments Off on Samsung Email’s auto-fit is breaking your emails (and how to fix it)
Article by Mark Robbins
Samsung Email’s auto-fit feature can dramatically change how your emails render on mobile. Learn why it happens, how it breaks layouts, and the surprisingly simple fix.
The MSO will only apply to Outlook but if you want to apply regular styles, or any HTML/CSS code to Outlook only, you can use MSO conditional comments. Here’s a good article on the subject.
emaildevComments Off on AMPscript: Check first character of string
I needed to see if a string started with a certain letter. The thing that made this easy was that I only needed to check for 2 different letters.
%%[
SET @OFFERCODE = "H8675309"
SET @OFFERCODE_H = IndexOf(@OFFERCODE,"H")
SET @OFFERCODE_A = IndexOf(@OFFERCODE,"A")
IF @OFFERCODE_H == 1 THEN
SET @QUOTE_URL = "https://partners.viubyhub.com/ahishondardremail1"
ELSEIF @OFFERCODE_A == 1 THEN
SET @QUOTE_URL = "https://partners.viubyhub.com/ahisacurardremail1"
ENDIF
]%%
What I’m doing here is getting the index of a certain letter inside a string, and if that index is “1” I know it’s the first letter.
@OFFERCODE_H = IndexOf(@OFFERCODE,”H”)
If @OFFERCODE_H is equal to 1, then I know H is the first letter.
If you need to find out the first or last character of a string, you can do this using the Length() and Substring() functions.
SET @STRING = "ABCDEFG"
SET @STRING_LENGTH = Length(@STRING)
SET @STRING_FIRST = Substring(@STRING, 1, 1)
SET @STRING_LAST = Substring(@STRING, @STRING_LENGTH, 1)
I was seeing the code at the end of the preheader in my inbox, specifically using Outlook (office 365) Windows desktop.
It looked to be coming from the hidden preheader code in the body of the email. The code looked like this (just after the opening tag):
<!--[if !mso 9]><!-->
<span style="display:none !important;visibility:hidden;opacity:0;color:transparent;height:0;width:0;">
%%[
set @rowCount = 175
for @counter = 1 to @rowCount do
]%%
‌
%%[ next ]%%
</span>
<!--<![endif]-->
What this code is/was for is to hide content at the top of the email that will only show up as the preheader in inboxes. We don’t want the content to actually show in the body of the email. In this example though, the content we are hiding is really only some spaces ( ‌). Those spaces are there to ensure that the preheader/pretext doesn’t show any unwanted content from the email. In this email, we are using the SalesForce Marketing Cloud’s “preheader” function , which gives you a place to put your subject line and preheader, and then at the time of send, it inserts that preheader copy into the top of the email. That works fine, but in some email clients, and if the preheader is kind of short, you will send some content pulled from the body of the email just after the preheader text.
So, if your preheader is “Great new deals for you”, and in the body of the email the first sentence is “Hello valued customer.”, then without those spaces you might see
“Great new deals for you Hello valued customer.”
In the code example, we are using AMPscript to create a bunch of inside a hidden . The AMPscript has a loop that shows those two characters 175 times, so it renders
‌ ‌ ‌ ‌ etc.
Since it’s inside a hidden span those spaces don’t show up in the body of the email, but the preheader does, and it puts them after the preheader that is pulled in from the “preheader” field in the Marketing Cloud email email. Again, that preheader is inserted at the top of the email, before those spaces are pulled in.
If you don’t want to use the SFMC preheader field, you can put your preheader text inside the hidden , just before the AMPscript that renders all the spaces. Then your inbox will use that text as the preheader.
But in my example, the hidden <span> is just used to insert all the spaces.
There was, in the past, an issue with Outlook not hiding the . It was ignoring all the CSS used to hide it, display:none;visibility:hidden; etc. so we added some MS conditional comments to ensure the is hidden in the body of the email.
But, something in that code was failing in Outlook Win desktop and we were seeing in the preheader in our inbox.
One thing that fixed it was just reformatting the code.
<!--[if !mso 9]><!-->
<span style="display:none !important;visibility:hidden;opacity:0;color:transparent;height:0;width:0;">
%%[ set @rowCount = 175
for @counter = 1 to @rowCount do ]%%%%=v(@PRE_HEADER)=%% ‌%%[ next ]%%
</span>
<!--<![endif]-->
What did this do? Why did this work? I’m not sure. The thing could be a Outlook, or a SFMC bug that is a bit random.
Another fix is to remove the conditional comments and just add mso-hide:all to the . This Outlook-specific code will hide the content from Outlook.
emaildevComments Off on GET IP address with AmpScript and SSJS
Here’s one way to get a visitor’s IP address using AmpScript and a 3rd party API.
%%[
SET @ip_AS = HTTPGet("https://api.ipify.org")
]%%
Here’s one way to get a visitor’s IP address using Server-Side JavaScript.
<script type="javascript" runat="server">
Platform.Load("core","1");
var ip = Platform.Request.ClientIP();
Write("Your IP SSJS: " + ip);
</script>
When testing this, these two methods produced different IP addresses. And when I go to a site the shows my IP address, that address is different than the other two my code is producing, so I’m not confident about this code.
This code will creat a dynamic QR code using a 3rd party API. We first create a URL to send to the API. Then we create the URL for the API call with that variable and assign that to the SRC parameter of an IMG tag.
%%[
set @data = "https://targetbaes.com"
set @qrcode = concat("https://api.qrserver.com/v1/create-qr-code/?size=300×300&data=",@data)
]%%
<img src="%%=v(@qrcode)=%%">