Skip to main content

Get Global Custom Code

GET/v2/project/{project_key}/global-custom-code

Return the project's Global Custom Code: JavaScript and CSS that already run on every page with the Mida pixel. Empty strings mean nothing is set yet. Call this before appending a custom-event snippet so existing code is kept.

Path parameters

ParameterDescription
project_keyYour project's API key

Example

curl "https://api-{region}.mida.so/v2/project/YOUR_PROJECT_KEY/global-custom-code" \
-H "Authorization: Bearer YOUR_GENERATED_API_KEY"

Success response

{
"success": true,
"js": "window.mdq = window.mdq || [];\nwindow.mdq.push([\"track\", \"signup\", { \"value\": 1 }]);",
"css": "",
"js_bytes": 78,
"css_bytes": 0,
"note": "This already runs on every page with the Mida pixel. To add a custom event, APPEND with update_global_custom_code (append_js) so the existing code stays."
}

Response fields

FieldTypeDescription
jsstringCurrent Global Custom JavaScript. Empty string if none is set
cssstringCurrent Global Custom CSS. Empty string if none is set
js_bytesnumberUTF-8 byte length of js
css_bytesnumberUTF-8 byte length of css
notestringGuidance for agents: prefer appending rather than replacing

Each file is stored as MySQL TEXT (65,535 bytes). This code runs on every page where the Mida pixel is installed, which is why a custom event does not need a change on the customer's site.

To add a snippet, Update Global Custom Code with append_js rather than replacing js.

Error responses

StatusMeaning
401Invalid or missing API key
403Project is inactive
404Project not found