Integrating SendGrid with Planet Press email templates

Hi there,

Please pardon my ignorance, but, I am having difficulty understanding how to integrate SendGrid with our email template.

I would like to add an unsubscribe link to the email which is consumed by SendGrid yet am clueless as to where to place the code and what to even put. I do not find the API’s helpful…perhaps due to my lack of experience in this area.

Thank you

I took a quick glance at their API and it honestly does not look like anything you’d use directly in an email.

Rather, it looks like the email should contain a hyperlink to a webpage that you are hosting. That webpage would then be built using their API to allow the client to unsubscribe from one or all of the mailings they belong to.

For the email template, this means you’ll need to insert a dynamic hyperlink. More on that here:

https://learn.objectiflune.com/en-us/planetpress-connect/howto/dynamically-insert-a-hyperlink

You may also find this useful for passing the client’s information up to the web server:

https://learn.objectiflune.com/en-us/planetpress-connect/howto/passing-record-data-to-your-frontend-web-page

Thanks for the reply AlbertsN. However, what SendGrid requires you to do, is add a small script to the JSON SMTP API Header that gets processed by SendGrid.

I am unclear how this is done. If its documented by Objectif Lune, it is not done very well as we have scoured the Manual/API’s and nothing references that yet Objectif Lune advertises that it supports integration with SendGrid yet does not offer instruction based on requirements described in SendGrid or MailChimp etc…ie how to add a JSON script to a SMTP header…

Ah, I see. There’s actually a section in the user guide that deals specifically with creating the custom header and even uses sendgrid as an example.

http://help.objectiflune.com/EN/planetpress-connect-user-guide/1.6/#designer/Output/Email/ESPs.htm

To insert the custom header, you’ll use a custom Control Script on the email context. There is a sample script you can use in the link above to get you started. Just open your design template, insert a new Control Script, and paste in the code. Obviously you’ll need to modify it a bit before you can get started as, by default, the only thing it’s going to put in the resulting JSON string is junk data.

Where you see the headerObj variable, that is where you’re going to insert data from your datamapping. You’re essentially creating the json data here, then passing it through the stringify command before including it in the header. Remember that you access your data fields using the ‘record.fields[“fieldName”]’ format.

Thank you sir…I found the link a few minutes after I posted and felt much shame…

It works beautifully. It was just very difficult to find.

My next question, which is related, is how to manage the unsubscribe link that gets added by SendGrid. Can the designer control the location of placement of the unsubscribe link? I have not figured this part out.

No trouble, and don’t worry about it. Sometimes it helps just to talk through an issue and we end up finding our own solutions that way.

Now, as for your unsubscribe link… I found some information that may help you.

From that, it looks a bit like you need to generate the URL in their management console, and then on the email itself you need to provide a ‘dummy’ url that will look like this:

<a`` ``href=``'[unsubscribe]'``>``Click Here to Unsubscribe``</a>

You should be able to place that anywhere in your design document and when the email gets sent through, their server will replace that placeholder href tag with the proper link. To do this without going into the source code, you can type ‘Click Here to Unsubscribe’ in your document wherever you like, highlight it, right click it and select Hyperlink… and Insert… then type ____ [unsubscribe] in the URL field.

Thank you again. I had found that as well and tried it, but that did not work. There are a few areas on there website exists, to which we have tried including Replacement Tags: