Skip to content

Commit

Permalink
First version of Marketo integration with Munchkin tracking script.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmerich committed Mar 4, 2025
1 parent 497ee68 commit 99589e2
Showing 9 changed files with 142 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bun.lock
Original file line number Diff line number Diff line change
@@ -551,7 +551,7 @@
"name": "@gitbook/cli",
"version": "0.20.1",
"bin": {
"gitbook": "./cli.js",
"gitbook": "./cli.js"
},
"dependencies": {
"@gitbook/api": "*",
Binary file added integrations/marketo/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integrations/marketo/assets/marketo-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions integrations/marketo/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: marketo
title: Marketo
icon: ./assets/icon.png
description: Use Marketo's automation platform (part of the Adobe Experience Cloud) with your GitBook docs.
previewImages:
- ./assets/marketo-preview.png
externalLinks:
- label: Documentation
url: https://www.gitbook.com/integrations/marketo
visibility: private
organization: gitbook
script: ./src/index.ts
scopes:
- site:script:inject
contentSecurityPolicy:
script-src: |
https://munchkin.marketo.net;
connect-src: |
munchkin.marketo.net
*;
summary: |
# Overview
Marketo Engage is a complete AI-powered marketing automation platform, and part of the Adobe Experience Cloud. This integration provides support for Marketo forms and the Munchkin tracking script.
# How it works
This integration allows you to connect the Munchkin tracking script to your GitBook docs site, and embed Marketo forms in your content.
# Configure
You can enable the integration on single published space by navigating to the sub-navigation and clicking on Integrations button. If you prefer to enable the integration or multiple or all published spaces you can do so by navigating to the org settings and clicking the Integrations tab. You will need your Domain to finish the configuration.
categories:
- analytics
- content
- marketing
configurations:
account:
properties:
account:
type: string
title: Munchkin Account ID
description: Your account ID, found under Admin > Integration > Munchkin menu.
required:
- account
target: all
4 changes: 4 additions & 0 deletions integrations/marketo/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.raw.js' {
const content: string;
export default content;
}
18 changes: 18 additions & 0 deletions integrations/marketo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@gitbook/integration-marketo",
"version": "0.1.0",
"private": true,
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*"
},
"devDependencies": {
"@gitbook/cli": "workspace:*",
"@gitbook/tsconfig": "workspace:*"
},
"scripts": {
"typecheck": "tsc --noEmit",
"publish-integrations-staging": "gitbook publish .",
"check": "gitbook check"
}
}
45 changes: 45 additions & 0 deletions integrations/marketo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
createIntegration,
FetchEventCallback,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

import script from './marketoMunchkin.raw.js';

type MarketoRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
account?: string;
workspace?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: MarketoRuntimeContext,
) => {
const account = environment.siteInstallation?.configuration?.account;
const workspace = environment.siteInstallation?.configuration?.workspace || '';

if (!account) {
return;
}

return new Response(
(script as string).replace('<account>', account).replace('<workspace>', workspace),
{
headers: {
'Content-Type': 'application/javascript',
'Cache-Control': 'max-age=604800',
},
},
);
};

export default createIntegration<MarketoRuntimeContext>({
fetch_published_script: handleFetchEvent,
});
25 changes: 25 additions & 0 deletions integrations/marketo/src/marketoMunchkin.raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// https://experienceleague.adobe.com/en/docs/marketo/using/product-docs/administration/additional-integrations/add-munchkin-tracking-code-to-your-website
(function () {
let didInit = false;
const document = window.document;
const accountId = '<account>';
const workspace = '<workspace>';

function initMunchkin() {
if (didInit === false) {
didInit = true;
Munchkin.init(accountId, workspace.length ? { wsInfo: workspace } : undefined);
}
}
const s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//munchkin.marketo.net/munchkin.js';
s.onreadystatechange = function () {
if (this.readyState == 'complete' || this.readyState == 'loaded') {
initMunchkin();
}
};
s.onload = initMunchkin;
document.getElementsByTagName('head')[0].appendChild(s);
})();
3 changes: 3 additions & 0 deletions integrations/marketo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}

0 comments on commit 99589e2

Please sign in to comment.