Code Snippets

A collection of useful code snippets and components.


Showing 10 of 10 snippets
SSJS

Secure a CloudPage for logged in users

Implements a secure OAuth 2.0 Authorization Code flow to protect a Cloud Page. Requires an Installed Package with a "Web App" API Integration in SFMC.Handles token validation, secure cookie sessions, and optional client-side token handoff.

HTML
14 copies
SQL

Extract URL Parameters in SQL

Extract URL parameters from URLs in SFMC. Useful for querying the _Click data view or other Data Extensions that contain Link data you want to use.

SQL
15 copies

Get the latest snippets

Join 2,000+ engineers receiving new marketing engineering patterns and snippets every month.

SSJS

Object-Oriented SSJS Pattern (Logger)

A reusable Logger class using the Prototype pattern. It standardizes how you write logs to a Data Extension, handling timestamps, error parsing, and severity levels automatically. use the prototype approach to define logic that belongs to an object (A function in this case).

SQL
2 copies
AMPScript

ContentBlockByKey

A modular architecture pattern using ContentBlockByKey to load reusable content assets dynamically based on subscriber context, facilitating easier maintenance than ContentBlockByID.

JavaScript
1 copy