Is there an easy way to extract all the campaign code and the campaign name from Marketing Cloud? I’m surprised it’s not part of the query which we could extract.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There’s no data view or standard extract, but you can get the list of all Campaigns and their associated attributes – Code, Name, Colour etc from the REST API’s /hub/v1/campaigns route. The response looks like this:
HTTP/1.1 202 Accepted { "page": 1, "pageSize": 2, "count": 2, "links": { "self": { "href": "/v1/campaigns?$page=1&$pagesize=2&$orderby=Name ASC&$orderBy=Name+Asc" }, "next": { "href": "/v1/campaigns?$page=2&$pagesize=2&$orderby=Name ASC&$orderBy=Name+Asc" } }, "items": [ { "id": "301", "createdDate": "2012-11-29T16:18:31", "modifiedDate": "2012-11-29T16:18:30", "name": "2012 Master Campaign", "description": "This is the Primary Campaign", "campaignCode": "master2012", "color": "d2e7b8", "favorite": false }, { "id": "310", "createdDate": "2012-11-29T16:18:31", "modifiedDate": "2012-11-29T16:18:30", "name": "East Coast", "description": "East Coast Only", "campaignCode": "EASTCOAST", "color": "d2e7b8", "favorite": false } ] }
Then, if you want to understand which emails etc are associated with a given campaign, you’d use the /hub/v1/campaigns/{id}/assets route to retrieve all the “assets” used in the Campaign:
HTTP/1.1 202 Accepted { "page": 1, "pageSize": 50, "totalCount": 3, "entities": [ { "id": "20", "campaignId": 330, "type": "TRIGGERED", "objectID": "1bef7d61-cb0b-e111-bb7b-1c659d025f52", "createdDate": "2012-12-19T14:49:23" }, { "id": "19", "campaignId": 330, "type": "AUTOMATION_DEFINITION", "objectID": "5e8baeea-1cf8-4c84-bf09-655a66afa2d5", "createdDate": "2012-12-19T14:49:23" }, { "id": "17", "campaignId": 330, "type": "EMAIL", "itemID": 7888, "createdDate": "2012-12-19T14:49:23" } ] }
The “itemid” in this response is the EmailID as it appears in your _Job Data View that’s accessible through Query Activity. To get all this data in Data Extensions, you’d need to write something like an SSJS Activity for Automation Studio.
Method 2
I wish it was. The only thing that I’ve found is the CampaignID
in the Sent file in a Tracking Extract.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0