1

Is there a way to retrieve SFMC mobilepush contact data/activity history data via ssjs/script that is generated in automation studio? For example, mobile contacts who are opted in who have been in a mobilepush campaign who have been a mobile subscriber for the past 12 months (in a child business unit)? I haven't been able to find much about retrieving data via wsproxy aside from what I've been able to find on https://sfmarketing.cloud/

1

To get push activity data, you can set up the Automation to run the Push Message Detail Report that places a file on the FTP that you can then import to a data extension. There's also the MobilePush Detail Data Extract that you can ask Support to provision that extracts much the same data as you see in the report.

To get MobilePush contacts, the REST API is the place to look, rather than SOAP/WSProxy that are focused primarily on the email channel. The REST route of interest is /contacts/v1/addresses/search. Here's some stripped down SSJS missing the getting of an Access Token and paging logic to get further pages beyond the first page of 2K records.

<script runat="server">
  Platform.Load("Core","1");
  var tssd = "my account specific api subdomain";
  var token = "my rest access token got elsewhere";
  var endpoint = "https://" + tssd + ".rest.marketingcloudapis.com/contacts/v1/addresses/search/Channel?$pageSize=2000&$orderBy=contactKey%20ASC&$page=1";
  var payload = '{"filterConditionOperator":"Is","filterConditionValue":"PUSH"}';
  var content = [0];
  var statusCode = Platform.Function.HTTPPost(endpoint, 'application/json', payload, ['Authorization'], ['Bearer ' + token], content);
  var batch = Platform.Function.ParseJSON(content[0]);
  Write(Stringify(batch));
</script>

Here's an abbreviated version of the response:

{
    "pageNumber": 1,
    "pageSize": 2000,
    "totalCount": 0,
    "addresses": [
        {
            "contactID": {
                "type": "string",
                "value": "15508978"
            },
            "contactKey": {
                "type": "string",
                "value": "01083e40-4cb3-4383-ac18-e58c96dc42a4"
            },
            "contactTypeID": 0,
            "addressTypeID": 9,
            ...
            "status": 0,
            "ordinal": 0,
            "source": 13,
            "modifiedDate": "2020-05-08T03:33:32.517",
            "valueSets": [
                {
                    ...
                    "name": "Primary",
                    "values": [
                        {
                            "objectState": "Created",
                            "objectValidationState": "Unknown",
                            "definitionID": "e2057a81-fefc-48a7-9bff-7a5ef379e7d6",
                            "valueDefinitionID": "e2057a81-fefc-48a7-9bff-7a5ef379e7d6",
                            "definitionKey": "OptInStatusID",
                            "valueDefinitionKey": "OptInStatusID",
                            "definitionName": "OptInStatusID",
                            "name": "OptInStatusID",
                            "valueID": "4b8a1329-cff8-476a-b829-054dcfea1c13",
                            "innerValue": "0"
                        },
                        {
                            "objectState": "Created",
                            "objectValidationState": "Unknown",
                            "definitionID": "a489e3bf-1dc7-47c0-a653-7f4a91aec2eb",
                            "valueDefinitionID": "a489e3bf-1dc7-47c0-a653-7f4a91aec2eb",
                            "definitionKey": "CreatedDate",
                            "valueDefinitionKey": "CreatedDate",
                            "definitionName": "CreatedDate",
                            "name": "CreatedDate",
                            "valueID": "8903628a-0940-4437-a653-d4f9d3387863",
                            "innerValue": "5/9/2020 7:42:46 AM"
                        },
                        ....
                    ]
                }
            ]
        }
    ],
    ....
}

You'll need to pull all this data (detail reporting and contact addresses) into data extensions in order to be able to answer the question, "who have been in a mobilepush campaign who have been a mobile subscriber for the past 12 months".

| improve this answer | |
  • This is helpful, greatly appreciated. I'm ultimately trying to merge the mobile contact data with the activity data (i.e. tie the mobile contact to the mobile campaigns they opted into and the date they opted in). Is this possible to do with the REST API? – esgreenberg May 14 at 20:53
  • Not directly, I'm afraid. You'll have to basically pull out the contact and activity data separately and stage it somewhere (eg: Data Extensions or external database) and then do your reporting on the staged data. – Macca May 14 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.