Optimizing Marketing Cloud Develoment

 

Do you regularly encounter challenges when developing, deploying or creating prototypes for your connected Marketing Cloud solutions? My background in web and software development in general helped me a lot to get going quickly. In this article I’ll share some of my favorite tools with you.

The Basics

Let’s start with the development basics: You need a great editor to write your code in and you should use some kind of versioning so you can go back to an older version if something goes wrong.

Editor with AMPscript highlighting

In case you like to have a development environment with AMPscript syntax highlighting as well as Salesforce CRM development capabilities (Apex syntax highlighting, Salesforce DX support, etc.) - “Visual Studio Code” is the right (and free) tool to use. Oh and it also has syntax highligting features for other languages that might come in handy for you - for example SQL.

Just make sure to install the packages you need by searching the extensions library for “AMPscript” or “Salesforce DX” for example and checking out the official extensions developed by Salesforce. A plugin you should definitely check out is “vscode-ampscipt” by Sergey Agadzhanov (a Lead Solution Engineer at Salesforce) that adds syntax highlighting, auto completion, tooltips with function reference and even lets you connect to Marketing Cloud using the API in order to edit your assets directly.

I generally recommend writing your code in an offline editor and then copying it to your Marketing Cloud instance (or serving it through a coud service) for these reasons:

  1. Did you ever accidentally swipe on your laptop’s touchpad and thereby moved in the browser history? I bet you did and lost the recently written code.
  2. You might say there is the autosave feature, right? But thats the next reason. What if someone else opens your email/cloudpage and modifies something - maybe also accidentally - autosave overwrites your code with the unintentional edit.
  3. For code solutions the editing experience of an offline editor is a lot better than those of most online editors.

Version Control

Reason two of the above section is just one among many why you should use version control. Version control also adds a layer of documentation, as you can add a comment for every change you make. When working in teams that’s a great feature. Furthermore it is possible to work on the same piece of code in parallel and merge the changes of two developers together later.

In traditional software development version control already is a standard for a long time, so why shouldn’t it be with code you write for Marketing Automation?! As the solutions get more complex and require more code I don’t see any reason why it should be treated differently to traditional software development.

My personal favorite and open source version control software is called “Git”. You can use it locally for yourself, have it on your company’s servers to work in teams or use it as a cloudservice on Bitbucket or GitHub for example. If you use cloud services, just make sure to sign up for the private ones if you don’t intend to host your code publicly! There is a lot of great resources about git, that you can find online or in your favorite bookstore. Git even has an integration in Visual Studio Code, the editor that I mentioned earlier.

Additional tip: Using a cloud service for your git repository or even a filesharing service such as dropbox together with CloudPages can save you a lot of time, as updates in your code are immediately reflected without having to wait for the page to publish (which can take up to five minutes).

The CloudPage only includes the following line of code which loads your real code from the cloud service of your choice:

%%=TreatAsContent(HTTPGet('https://cloudservice.com/yourampscript.html'))=%%

That tip is one of Salesforce MVP Eliot Harper’s favorite AMPscript hacks. To find out more about AMPscript tips & trick from him, check out my Lookup(Answers) webinar wrap-up.

Note: Make sure to only do this with code that doesn’t contain any sensitive information and avoid doing this in production altogehter!

Prototyping

Now that you have your deleopment setup, I want to take you a step back again. How do you approach developing solutions? If you are like me I have a thought in my mind on how something could be done, scribble it down with pen and paper and for more complex solutions I like to verify that quickly. If a solution is based on a more complex data model and maybe some data sources or objects that aren’t already synced to Marketing Cloud that can be a bit challenging - especially if you find out that it won’t work out that way and you might need to approach that solution differently. Trying out API endpoints to see if they help get your desired stuff done without writing a single line of code sounds nice too, right?!

SQL prototyping/development

Thats the case for many things but one stands out because it requires a lot of effort to try it out - developing complex SQL statements that involve a lot of logic, maybe aggregations, groupings and so on. So before all the integration work is done, I sometimes create some simplified test-tables and run test-queries. Due to the fact, that you need to have the data extensions (= database tables) and query activities in Marketing Cloud, that can take up a good amount of time.

Oh and seeing error messages would be great too, right? As Marketing Cloud doesn’t expose them that openly, you might think about other options. You sure don’t want to set up your own Microsoft SQL server to imitate Salesforce Marketing Cloud’s behavior just for that prototyping, right?! “SQL Fiddle” is just the right tool for you. It lets you create tables and run queries directly from your browser to see if you get the expected result or which error might occur.

Note: I’ve seen some stability issues in the past, but I like it a lot and am sure it can be helpful for you too!

If you already have all the data strucutres set up in Marketing Cloud and just want to try out some SQL queries, the AppExchange app “Query Studio for Marketing Cloud” developed by Salesforce Labs might be right for you.

JavaScript prototyping

If you need to perform an easy task quickly and programmatically - like converting a timestamp, generating a pseudorandom number for a random draw, URLencoding something, etc. - or want to try out a short JavaScript snippet (that doesn’t contain any Marketing Cloud specific SSJS code) you’ll definitely like “JSFiddle”. It even lets you add HTML and CSS code to try out some FrontEnd code for your landingpages.

API interaction prototyping

Let’s say you found out about a new API endpoint in Marketing Cloud, that sounds like a perfect fit for one of your new projects. Building everything to then find out it doesn’t work like expected would set you back to the starting point and you’d miss your deadline. To avoid that, using a tool that lets you send API requests without any code is the right thing to do.

Using Postman you just need to prepare the data you like to transmit, authenticate your request and hit send. The response is directly displayed on your computer and you can use it to build your script/program around it. Saving and sharing common requests is also easy as the request collections can be exported as JSON file.

A lot of prepared requests for the Marketing Cloud API are also available to download on api.mcexperts.ninja.

Testing API integrations

Imagine having an external system that needs to connect to Marketing Cloud API, a custom endpoint you create or the other way round and the result isn’t as desired, but you don’t have access to any server logs. If you dealt with any such scenario the onlinetool “Requestbin.com” might come in handy for you.

It lets you create an online endpoint - the so called “request bin” - that accepts requests and displays those requests in the UI. You can see if all the headers are correct, the payload is encoded correctly and contains the anticipated data and a lot more.

My most recent uses of Requestbin.com:

  • I wanted to try out the Event Notification Service without having to create an endpoint for the notification webhook. (→ stay tuned for my upcoming blogpost, that will cover this feature)
  • A coworker built an integration with the Marketing Cloud API and something didn’t work. So I let my colleague change the endpoint to a requestbin and voila we could figure out the problem in just a couple of minutes!

Deployments

Do you work in a Marketing Cloud instance with multiple business units? And do you happen to use a “sandbox” or staging system for your new developments? That isn’t uncommon and sometimes necessary. If you are working with a Cross-Cloud setup with a lot of connected systems - say Sales/Service Cloud, Commerce Cloud and so on - you may be dependent on deployments in these systems and are bound to a specific release. In order to be ready to go once the deployment happens in the other clouds developing towards a connected Staging environment may be necessary.

What about deployments in Marketing Cloud? Is that even possible?

Unfortunately Marketing Cloud doesn’t provide a deployment process out-of-the-box. So bringing your developments to the production environment usually involves a lot of rebuilding and copy & paste action or if you were tired of that at some point maybe custom API-powered solutions.

But things have been getting a lot better recently, as Salesforce Labs started providing a solution with the AppExchange app called “Deployment Manager for Marketing Cloud”. The current functionality (November 2020) includes importing/exporting the following:

  • journey flows (the canvas structure)
  • data extension schemas
  • automations (partial support only)
  • contact model attribute groups (partial support only)

The featureset is growing and I expect to see a fully-fletched deployment process in the future!

Tip: Add the exported information to a Git repository to also have a versioning/backup of these assets.

Developer Tools

Sometimes the Marketing Cloud user interface hides stuff from you, that you may need for your developments and integrations. That could be IDs, keys, information about the instance or just error messages. All this information is available when checking the data that is passed to the browser - it just isn’t displayed. To be able to see this information I created a plugin for Google Chrome, that shows it.

Check out the current features on the Salesforce Marketing Cloud - Developer Tools page, install it from the chrome web store or contribute to the plugin by submitting a pullrequest on GitHub.

Find all the mentioned tools and websites below, so you can check them out:

Presentation slides

Do you have anything to add?

Is there anything you love to use and like to share? Please let me know via email or private message on LinkedIn.