diff --git a/.gitignore b/.gitignore index 92624863..828494f8 100644 --- a/.gitignore +++ b/.gitignore @@ -158,4 +158,4 @@ dmypy.json # Cython debug symbols cython_debug/ -# End of https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks +# End of https://www.toptal.com/developers/gitignore/api/python,jupyternotebooks \ No newline at end of file diff --git a/docs/campaigns/exporting_campaigns.rst b/docs/campaigns/exporting_campaigns.rst new file mode 100644 index 00000000..c26e57ee --- /dev/null +++ b/docs/campaigns/exporting_campaigns.rst @@ -0,0 +1,123 @@ +.. vale off + +Exporting Campaigns +################### + +.. vale on + +Before importing or exporting data, as a safety precaution take a backup of your database so that you can restore data if required. Speak to the administrator of your domain to be able to do this as it requires specific technical knowledge. + +.. important:: + Both the import and the export features are only available in Mautic 7.0 and later versions. + +Supported data types +-------------------- + +When you select a Campaign, the export feature extracts all Campaign data and entities and any dependencies the Campaign needs to function. This includes: + + - Dynamic Content + - Assets + - Custom Fields + - Other related dependencies + +The export command: + + - Detect use of Plugins and Custom Fields + - Include the data to support these dependencies + +.. important:: + The importing instance needs the same Custom Fields and Plugins to be present. + +.. vale off + +How exporting Campaigns works +***************************** + +.. vale on + +Whether exporting via the UI, the command line or using the API, the Export feature +follows the same process. + + - Checks that the User has adequate permissions to export + - Supports exporting multiple Campaigns simultaneously + - Exports data in a structured JSON format + - Exports Assets into a separate folder in their original format + - Zips the resulting collection of files for easy transfer across systems + +Export methods +************** + +You can use the Export feature in three ways: + +UI-based export +--------------- + +Manual export through Mautic Campaigns dashboard: + +# Go to the Campaigns menu +# Select the Campaign you want to Export +# Select the Export option from the dropdown menu located next to the item selection + +CLI-based export +---------------- + +Use the following commands: + +.. code-block:: bash + + bin/console mautic:entity:export --entity=campaign --id=1 --zip-file --path=path/to-file + +* `entity` defines the type of entity to Export, in this case `campaign` +* `id` defines the id of the Campaign to Export. Look at the URL to find the ID when you view or edit the Campaign - the ID appears in the URL for example, ``/s/campaigns/view/123`` where 123 is the ID +* `zip-file` creates a zip file of the Campaign and its dependencies +* `path` specifies the directory to save the exported file. + +.. code-block:: bash + + bin/console mautic:entity:export --entity=campaign --id=1 --json-file + +* Creates only a JSON file and ignores any additional resources + +API-based export +---------------- + +You can export Campaigns programmatically using the Mautic API. You need to authenticate for the API request. using the API credentials stored in Mautic's settings. For more detail on how to authenticate, see the :doc:`Mautic API documentation authentication/authentication.html`. + +Curl example +************ + +.. code-block:: bash + + curl --location 'https://{your-mautic-domain}/api/campaigns/export/1' \ + --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ + --data '' + +Python example +************** + +.. code-block:: python + + import requests + + # API Endpoint + campaign_id = 1 + url = f'https://example.com/api/campaigns/export/{campaign_id}' + + # Authentication + headers = { + 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' + } + + # Send export request + response = requests.get(url, headers=headers) + + # Handle response + if response.status_code == 200: + export_file = response.content + # Save or process the exported campaign + +.. important:: + - Replace `example.com` with your actual Mautic instance domain + - Replace `YOUR_ACCESS_TOKEN` with a valid authentication token + - The API uses a GET request to export a specific Campaign by ID + - Ensure you have the necessary API permissions diff --git a/docs/campaigns/images/activate-campaign.png b/docs/campaigns/images/activate-campaign.png new file mode 100644 index 00000000..064b5de2 Binary files /dev/null and b/docs/campaigns/images/activate-campaign.png differ diff --git a/docs/campaigns/images/campaign-sample.json b/docs/campaigns/images/campaign-sample.json new file mode 100644 index 00000000..e8a54b30 --- /dev/null +++ b/docs/campaigns/images/campaign-sample.json @@ -0,0 +1,573 @@ +[ + { + "campaign": [ + { + "id": 3, + "name": "Sample campaign file", + "description": "", + "is_published": false, + "canvas_settings": { + "nodes": [ + { + "id": 5, + "positionX": "379", + "positionY": "159" + }, + { + "id": 7, + "positionX": "772", + "positionY": "155" + }, + { + "id": 8, + "positionX": "73", + "positionY": "158" + }, + { + "id": 9, + "positionX": "506", + "positionY": "408" + }, + { + "id": 6, + "positionX": "213", + "positionY": "263" + }, + { + "id": "lists", + "positionX": "653", + "positionY": "53" + }, + { + "id": "forms", + "positionX": "947", + "positionY": "51" + } + ], + "connections": [ + { + "sourceId": "lists", + "targetId": 5, + "anchors": { + "source": "leadsource", + "target": "top" + } + }, + { + "sourceId": 5, + "targetId": 6, + "anchors": { + "source": "yes", + "target": "top" + } + }, + { + "sourceId": "lists", + "targetId": 7, + "anchors": { + "source": "leadsource", + "target": "top" + } + }, + { + "sourceId": "lists", + "targetId": 8, + "anchors": { + "source": "leadsource", + "target": "top" + } + }, + { + "sourceId": "lists", + "targetId": 9, + "anchors": { + "source": "leadsource", + "target": "top" + } + }, + { + "sourceId": "lists", + "targetId": "forms", + "anchors": { + "source": "leadsourceright", + "target": "leadsourceleft" + } + } + ] + }, + "uuid": "b4ddc4d7-149e-4a81-9141-0e03c598627a" + } + ], + "campaign_event": [ + { + "id": 5, + "campaign_id": 3, + "name": "Downloads asset", + "description": "", + "type": "asset.download", + "event_type": "decision", + "event_order": 1, + "properties": { + "canvasSettings": { + "droppedX": "313", + "droppedY": "158" + }, + "name": "", + "anchor": "leadsource", + "properties": { + "assets": [ + 2 + ] + }, + "type": "asset.download", + "eventType": "decision", + "anchorEventType": "source", + "campaignId": "3", + "_token": "0.oKNciNUEGsLHNnAw81-PkskwW94qK_8ClWqMXITDlz4.k5ZuwZo1VY6kZz5jvS-4-bNUD4h5ToVr3wHOa-OHp2mQ0xHfozNsiPIAGw", + "buttons": { + "save": "" + }, + "triggerDate": null, + "assets": [ + 2 + ] + }, + "trigger_interval": 0, + "trigger_interval_unit": "", + "trigger_mode": "", + "triggerDate": null, + "channel": "asset", + "channel_id": 2, + "parent_id": null, + "uuid": "2ea825c4-6086-4ec8-b355-44f7355d4bc0" + }, + { + "id": 7, + "campaign_id": 3, + "name": "Request dynamic content", + "description": "", + "type": "dwc.decision", + "event_type": "decision", + "event_order": 1, + "properties": { + "canvasSettings": { + "droppedX": "553", + "droppedY": "158" + }, + "name": "", + "anchor": "leadsource", + "properties": { + "dwc_slot_name": "test", + "dynamicContent": 1 + }, + "type": "dwc.decision", + "eventType": "decision", + "anchorEventType": "source", + "campaignId": "3", + "_token": "04feb2c5a9.SYXSFiT87s-Zw_AIqYLsKEyHuLu3w2dVy9oma5rraFw.GsjjfWq5r6LBgrl-2NO-ay7_7PmOkh8ls7QeIN2xKR0Yt4g7c5KPqfyklw", + "buttons": { + "save": "" + }, + "triggerDate": null, + "dwc_slot_name": "test", + "dynamicContent": 1 + }, + "trigger_interval": 0, + "trigger_interval_unit": "", + "trigger_mode": "", + "triggerDate": null, + "channel": "dynamicContent", + "channel_id": 1, + "parent_id": null, + "uuid": "21ec254c-68d5-4675-aae0-4d698676a9ce" + }, + { + "id": 8, + "campaign_id": 3, + "name": "Visits a page", + "description": "", + "type": "page.pagehit", + "event_type": "decision", + "event_order": 1, + "properties": { + "canvasSettings": { + "droppedX": "73", + "droppedY": "158" + }, + "name": "", + "anchor": "leadsource", + "properties": { + "pages": [ + 1 + ], + "url": "", + "referer": "" + }, + "type": "page.pagehit", + "eventType": "decision", + "anchorEventType": "source", + "campaignId": "3", + "_token": "5f8ffc233728216b01c925d3b1.-S7eUs8NTLUMFt8d0pR5J8yCaeCdnLbL4RAthmMKL8U.qmPvOYFIDdhUV5Zro8UrZK76PaKkzc67mX4VzSRQboSoHIR_mGMt02lxuA", + "buttons": { + "save": "" + }, + "triggerDate": null, + "pages": [ + 1 + ], + "url": null, + "referer": null + }, + "trigger_interval": 0, + "trigger_interval_unit": "", + "trigger_mode": "", + "triggerDate": null, + "channel": "page", + "channel_id": 1, + "parent_id": null, + "uuid": "2a29709f-0cf7-435e-afab-aff130965789" + }, + { + "id": 9, + "campaign_id": 3, + "name": "test", + "description": "", + "type": "lead.points", + "event_type": "condition", + "event_order": 1, + "properties": { + "canvasSettings": { + "droppedX": "10", + "droppedY": "263" + }, + "name": "test", + "triggerMode": "immediate", + "triggerDate": null, + "triggerInterval": "1", + "triggerIntervalUnit": "d", + "triggerHour": "", + "triggerRestrictedStartHour": "", + "triggerRestrictedStopHour": "", + "triggerWindow": "0", + "anchor": "leadsource", + "properties": { + "operator": "=", + "score": "1111", + "group": "1" + }, + "type": "lead.points", + "eventType": "condition", + "anchorEventType": "source", + "campaignId": "3", + "_token": "91d612e76a6bf.bDrd_GtYJSCQAa8oNqzeGhljlPlKZ9gy66WBo3Qer08.P3fslyUdZE3IQOZeR_2MWXsbwLtzNqBCk8u56DNE7g49CIfRPDZERvVmyA", + "buttons": { + "save": "" + }, + "operator": "=", + "score": 1111, + "group": 1 + }, + "trigger_interval": 1, + "trigger_interval_unit": "d", + "trigger_mode": "immediate", + "triggerDate": null, + "channel": "", + "channel_id": 0, + "parent_id": null, + "uuid": "bc70df3e-7d49-4d12-b6ad-992f1e3205a4" + }, + { + "id": 6, + "campaign_id": 3, + "name": "test", + "description": "", + "type": "email.send", + "event_type": "action", + "event_order": 2, + "properties": { + "canvasSettings": { + "droppedX": "213", + "droppedY": "263" + }, + "name": "test", + "triggerMode": "immediate", + "triggerDate": null, + "triggerInterval": "1", + "triggerIntervalUnit": "d", + "triggerHour": "", + "triggerRestrictedStartHour": "", + "triggerRestrictedStopHour": "", + "triggerWindow": "0", + "anchor": "yes", + "properties": { + "email": 1, + "email_type": "marketing", + "priority": "2", + "attempts": "3" + }, + "type": "email.send", + "eventType": "action", + "anchorEventType": "decision", + "campaignId": "3", + "_token": "fa386d8.ZuglYE5nMxIig26ZT_ooaIBQV5jFhTurjLKYxG0W_dM.NaUUCwAicn96wifvPqt6K-IoA9r81EPb9NygjypMvJI32n9NGQlSdEfkCQ", + "buttons": { + "save": "" + }, + "email": 1, + "email_type": "marketing", + "priority": 2, + "attempts": 3 + }, + "trigger_interval": 1, + "trigger_interval_unit": "d", + "trigger_mode": "immediate", + "triggerDate": null, + "channel": "email", + "channel_id": 1, + "parent_id": 5, + "uuid": "63077b6b-800b-4ed1-88ca-3267e3012947" + } + ], + "asset": [ + { + "id": 2, + "is_published": true, + "title": "stesetste", + "description": null, + "alias": "stesetste", + "storage_location": "local", + "path": "e2ac32c7d50379f5df60cc43d1e7181fa5e94ab9.png", + "remote_path": null, + "original_file_name": "icon_128x128.png", + "lang": "en", + "publish_up": null, + "publish_down": null, + "extension": "png", + "mime": "image\/png", + "size": 10, + "disallow": true, + "uuid": "21a5c18a-3c34-4871-92c1-b698eb5ac80f" + } + ], + "dynamicContent": [ + { + "id": 1, + "translation_parent_id": null, + "variant_parent_id": null, + "is_published": true, + "name": "test", + "description": null, + "publish_up": null, + "publish_down": null, + "content": null, + "utm_tags": { + "utmSource": null, + "utmMedium": null, + "utmCampaign": null, + "utmContent": null + }, + "lang": "en", + "variant_settings": [], + "variant_start_date": null, + "filters": [], + "is_campaign_based": true, + "slot_name": "", + "uuid": "107ac8a2-ec01-4ea9-88e8-80d24e2a63bc" + } + ], + "page": [ + { + "id": 1, + "is_published": true, + "title": "test page", + "alias": "test-page", + "template": "blank", + "custom_html": "
\r\n \r\nHello there!<\/h2> |