Simple Marketing Cloud App hosted on a CloudPage

DISCLAIMER: The Marketing Cloud App component has been designed for use with externally hosted apps. Use any alternative solutions presented in this article with caution. The settings we are going to use are simplified compared to the ones required by externally hosted apps, so make sure that only designated users have access to the apps you create using this workaround.

A Marketing Cloud app is an externally hosted application that is iframed into Marketing Cloud. Marketing Cloud apps include custom apps built by your organization or apps installed from AppExchange. You launch an app via the Marketing Cloud app menu:

A common Marketing Cloud app you might be familiar with is Query Studio for Salesforce Marketing Cloud:

Query Studio

Query Studio is an externally hosted app, which lets you write and run SQL queries and instantly see the query results onscreen, with a similar experience to SQL Server Studio or MySQL workbench.

Another example of a Marketing Cloud app that you might be familiar with is Deployment Manager for Marketing Cloud:

Deployment Manager

Deployment Manager lets you import and export Marketing Cloud Configuration and easily distribute it to other Marketing Cloud Enterprises and Business Units.

Both those apps, Query Studio and Deployment Manager, have been developed by Salesforce Labs and are publicly available to download for free from AppExchange.

There are many more commercial apps for Marketing Cloud in AppExchange, all of them hosted externally. This means that for security, they all must use a web app or public app OAuth 2.0 integration to acquire an access token, and use that access token to request information about the end-user by calling the v2/userinfo REST endpoint.

Here’s a brief overview of creating an externally hosted Marketing Cloud app:

  1. Create an installed package, or navigate to an existing package.
  2. Under Components, click Add Component.
  3. Select Marketing Cloud App.
  4. Enter a name and description for your app.
  5. Enter your app’s login, redirect, and logout URLs. Point to localhost or test locations first, if needed, and edit these values later. All URLs must be HTTPS (TLS).
    • Login – Marketing Cloud uses this endpoint to iframe your externally hosted app. Your app can show anything here. Your app must set a cookie at login. To retrieve information about the end user, ensure that your externally hosted app immediately kicks off Marketing Cloud’s OAuth 2.0 authorization code flow and then calls the v2/userinfo route after calling your login endpoint. Legacy packages only: Marketing Cloud posts the JWT here.
    • Logout – Marketing Cloud performs a GET on the logout endpoint from the browser. This logout URL ends the user’s session and unsets the cookie set on login. When the user logs out of Marketing Cloud, the app session also ends.
  6. Save the component.
  7. Log out of Marketing Cloud, and log back in to see your app in the AppExchange menu in Marketing Cloud.

Source: Create a Marketing Cloud App

But what if you cannot, or don’t even want to build an elaborate, externally hosted app? If you’re looking for a simple, yet elegant solution that will only be used internally by you and your colleagues, hosting your app in Salesforce Marketing Cloud’s Web Studio might be the workaround that will fulfil your requirements.

My teams have built numerous Marketing Cloud apps that way. To give you some examples of what we used them for:

  • monitoring all journeys in the account,
  • monitoring all automations in the account,
  • creating robust email tracking dashboards,
  • creating functionalities to help users get their work done faster and with less manual steps.

Let’s get to it!

Create an app on a CloudPage

Let’s start by creating a simple app on a CloudPage. We can use an app I already described on this blog in the article called Find a Data Extension and it’s folder path using SSJS. Here is the full script you will need for your CloudPage:

Find a Data Extension and it’s folder path using SSJS

Now you can publish the CloudPage and test if it works correctly before we move on to the next step.

Create a Marketing Cloud App

Let’s now move on to the main Setup and in there to Platform Tools > Installed Packages. On the page with All Packages click on New to add a new package. Give the package a name and describe it’s function (note, that this name and description will only be visible to administrators who have access to setup in Salesforce Marketing Cloud).

In the Components section, click on Add Component and chose a Marketing Cloud App:

Now you will need to Set Marketing Cloud App Properties:

  • Name – the name of your app which will be visible for all users
  • Description – description of what your app does
  • Login Endpoint – the external URL of the CloudPage you created and published earlier, eg. https://pub.s10.exacttarget.com/xzy
  • Logout Endpoint – use the same URL as above

Once your app is saved, log out of Marketing Cloud and log back in, to see your app in the main menu, under the AppExchange icon, from where you can launch it:

Access and Sharing

Just like with all enhanced packages, you can license packages installed from parent business units to other business units across your enterprise. On top of that, you can choose which users should be able to access the app and from which BUs. This means that in a few easy clicks, you can either:

  • give access to the app to all users in all Business Units,
  • choose certain Business Units, where all existing and future users of those BUs would be granted access to the app,
  • or pick your designated users and choose in which Business Units they should be able to access the app.

Here’s a step-by-step guide on Licensing for Enhanced Packages:

Installed Packages in Marketing Cloud
Manage Licensing for Installed Packages
  1. From the detailed view for any package, click the Access tab to manage user licensing.
  2. Search for a business unit to grant or restrict licensing for the package. If you have only one business unit, the search field and tree is hidden.
  3. License specific users in the selected business unit. When users are added, add licensing for those users here.
  4. For server-to-server integrations only: To assign licenses to users or to make API requests on behalf of this business unit, enable the package’s server-to-server integration for that business unit. You can assign licenses only if the package contains another component in addition to the server-to-server API integration, which isn’t licensable. Enable Business Units isn’t shown for other integration types.
  5. License all current and future users in the business unit.
  6. For server-to-server integrations only: Enable the package’s server-to-server integration for all business units in your account. You can assign licenses to users in all business accounts and make API requests on behalf of all business units in your account. This option isn’t shown for other integration types.
  7. License all current and future users for all business units in your account. If this option isn’t shown, you don’t have permission to administer installed packages in all business units in your account. To gain access, work with your account administrator.

Make your users feel at home

If the app you’re planning to create will be processing a lot of data or multiple requests that might take some time, you can add a Salesforce-style spinner that your users are familiar with.

Now you’re all set, so have fun with creating your own app!


Questions? Comments?

Leave a comment below or email me at zuzanna@sfmarketing.cloud.

Salesforce-style spinner for use on CloudPages

Spinners are loading indicators that can be shown when retrieving data or performing other operations.

We will use a common spinner that Salesforce Lightening users are familiar with – the full documentation can be found here. This spinner is a Lightning component, which means that it cannot be directly used on a CloudPage. My awesome colleague Anna rewrote it into HTML and CSS, so that it can be easily copied and pasted for use on a CloudPage. This way, you can emulate the look and feel of other Salesforce clouds on your CloudPages.

It doesn’t necessarily add any value for external users of your CloudPages, but it can improve the experience of Salesforce Marketing Cloud users who internally use apps created on CloudPages and are familiar with other Salesforce clouds.

Here’s a preview of the spinner we will create in a few easy steps:

Let’s start with adding the CSS for our spinner. You can paste below code anywhere in your existing style-sheet, or create a separate one and link to it in the document head:

Now let’s add our spinner to the CloudPage. We will create an HTML button and add an onclick event, so that the spinner activates once the user clicks the button:

And finally, let’s add the script with the showSpinner() function:

Above function will activate the spinner once the button is clicked and it will run indefinitely, which means that it’s appropriate for any use cases where the website gets reloaded or redirected to another one after all operations have been completed.

If you would like to control for how long the spinner is displayed, you can use the setTimeout method to deactivate the spinner after a given time. Below script will hide the spinner after 5 seconds:

You can also control the activation/deactivation of the spinner by adding a hideSpinner() function to other functions used for performing operations. Below example will post data to another website using the fetch method and hide the spinner after the operation is complete:

To see the spinner in action, visit my demo CloudPage: https://pub.s10.exacttarget.com/c5luwxbwtxa.


Questions? Comments?

Leave a comment below or email me at zuzanna@sfmarketing.cloud.

Testing email load (download) speed

The size of an HTML email can impact both deliverability and subscriber engagement. An email that requires long time to load can lead to lost interest, that’s why it’s important to optimize your emails for better performance.

Acceptable email download speeds according to Email on Acid are:

  • 3G connection: Less than 4 seconds
  • 4G connection: Less than 3 seconds
  • LTE connection: Less than 2.5 seconds
  • Desktop connection: Less than 2 seconds

So how can you test your email load speed? The best way to do this, without the need to use third-party vendors or paid software, is to use Google Chrome DevTools.

Testing email download speed in Google Chrome

The first thing you will need to do is to send the email to yourself, and remember to include the View Email as Web Page link in the email body. Click on this link and open your email in Google Chrome Browser.

Next, you will need to open Chrome DevTools. There are several ways to do this:

  • press F12
  • right-click any element on the page and select Inspect
  • press Command+Option+C (Mac) or Control+Shift+C (Windows)

In the DevTools UI, click on the Network tab:

Next, click on No throttling and choose a preset:

Then, refresh the whole page either by clicking the refresh button next to the URL or by pressing F5. You will see how the email loads with all its content elements listed and their download times measured. At the bottom, you will find the final load speed:

Although the available presets do not have an option to use 4G or LTE, you can measure the download speed for 3G and compare it to the benchmark.

If the load time of your email is above the benchmark, you can optimize it by reducing the size of the images (anything above 200KB is considered a large image in email marketing) and by removing unused styles or any unnecessary characters from your code.

Preparing for the Salesforce Marketing Cloud Developer certification

Last week I passed the Salesforce Marketing Cloud Developer exam. Afterwards, I received a lot of questions about preparing for it and the test itself. That’s why I’ve decided to share how I prepared, what helped me pass it on the first attempt and hopefully will help you too.

Resources

First, familiarize yourself with the official exam guide. The exam guide suggests that you need at least a year of experience developing for Marketing Cloud. In particular, developing dynamic, personalized marketing assets such as emails, landing pages, and forms leveraging HTML, CSS, and AMPscript. You also need to be proficient in SQL and have experience in using Marketing Cloud APIs. I agree with that and hands-on experience with the platform, scripting and debugging is essential.

When it comes to online resources, you can start with the Develop for Marketing Cloud trail on Trailhead. There is official documentation available for AMPscript and SSJS, but I found Eliot Harper’s and Adam Spriggs’ AMPscript guide much more helpful. To learn about Marketing Cloud data architecture, download a free copy of The Data Handbook. It’s also worth reading Jeremy Garcia’s article about preparing for the exam. And of course, there’s the indispensable Salesforce Stack Exchange, where you will find tons of script examples, useful tips for debugging and Marketing Cloud development best practices.

Training

Currently, there are no official Salesforce training offerings for Marketing Cloud developers. Fortunately, from time to time, unofficial workshops and classes are organized. Keep track of the various communication channels, like the Salesforce Marketing Cloud Developer Groups on LinkedIn or Facebook to stay up to date.

Eliot Harper
Eliot Harper during the Marketing Cloud Developer training in Munich

I have been able to attend an intensive one-day Marketing Cloud Developer Masterclass organized by Eliot Harper in Munich this year. The scope of this training was much broader and advanced than what is needed for this exam, so do not be discouraged if you did not attend the training – hands-on experience with the platform is what counts the most for this exam.

Now let’s take a closer look at each of the five areas outlined in the exam guide. 

Data Modeling: 14%

For this part, you will need to fully understand Contact Builder, the various types and uses of data extensions and how to link them. You will need to be able to describe how Contact Records relate across channels. Make sure you know how Contact Deletion in Contact Builder works – all the possible methods and how they are processed by the system. Learn about Contact Delete Best Practices and how to track statuses of contacts during the deletion process. You also need to be familiar with a legacy Contact Builder feature called Channel Address Order.

Programmatic Languages: 35%

This is probably the most important part of the exam, and you will see questions not only related to AMPscript and SSJS syntax but also their performance and processing.

You can start with reading about AMPscript syntax and best practices. Even if you already have experience with scripting, it’s worth a thorough read before taking the exam. Make sure you fully understand the AMPscript Data Modification Functions and how Marketing Cloud processes them. Familiarize yourself with Date and Time FormattingOrder of Operationsand Personalization Strings in Email Studio. You need to know the most important Data Extension Functions by heart and be able to use them without looking at the documentation, so memorize all the required parameters. Make sure you know how to use the most common Content FunctionsDate & Time Functions, HTTP FunctionsMath FunctionsString Functions and Utility Functions. Read about some of the Site-Based Functions, like CloudPagesURLRequestParameter and QueryParameter. Understand where and how to use Exclusion Scripts and the RaiseError function. You also need to fully understand if/else statements and loops. The official guide clearly states that a candidate for this exam is not expected to know how to configure Marketing Cloud Connect, so you don’t need to worry about the Sales & Service Cloud Functions.

Familiarize yourself with Server-Side JavaScript syntax and the most common Core and Platform functions. Make sure you understand what is possible with SSJS and when, where and how to use it. Learn how AMPscript and SSJS talk to each other and how to combine them for debugging.

You will see all types of questions in this part of the exam, for example: which function to use for ABC use case; which of the following is the correct way to use XYZ function; or what the outcome of a script snippet will be.

API: 22%

Same as with scripting, you will need hands-on experience with API. You can use free software like POSTMAN to interact with your instance of Marketing Cloud and download the SFMC Postman collection or the Salesforce Marketing Cloud Enhanced API Collection.

First of all, you will need to know how to Create an installed package in your Marketing Cloud account, about Subdomains and Tenant’s Endpointsauthentication and how to use the access token in SOAP and REST calls.

Learn about the use cases for REST and SOAP API and memorize the most common routes,methods and objects – I was surprised how specific some of the questions were. Familiarize yourself with Errors in REST APISOAP Error Codes and how to resolve them.

Learn how to Optimize API Calls and Data Structures to Improve Performance.

Data Management: 22%

There were quite a few SQL questions on the exam, and similarly to the Programmatic Languages, you will need to know not only the correct syntax but also about the performance and processing, so start with reading about Query Activities Best Practices. You need to be proficient in using all the statements from the SQL Reference and to know the different kinds of JoinsString Functions and Date Functions. Take a look at the Query Examples in the official documentation and read how to Optimize the Query Activity. Pay attention to Data Views, think about the most common use cases and familiarize yourself with column names for the most frequently used data views. Learn how to Troubleshoot SQL Queries in Marketing Cloud.

Read about Send Logging – you will need to know how send logging works, how to Create an Email Send Logging Data Extension and about Send Logging Best Practices and Tips.

You also need to be familiar with importingtransferring and extracting data from Marketing Cloud.

Security: 7%

For the Security portion of the exam, you will need to learn about the different methods to secure data in Marketing Cloud, for example, Field-Level EncryptionTokenized SendingTransparent Data EncryptionKey Management and AMPscript Encryption and Encoding Functions. Read about API Integration Securityfile transfer security and SSL Certificationfor Cloud Pages. Understand data security best practices.

Conclusion

Overall, I found this exam a bit easier than the Certified Marketing Cloud Consultant one, as there was less room for ambiguity. For example, a lot of questions contained a script or a query snippet, and you simply had to choose the correct outcome.

Thank you for reading and good luck with your exam!