Unsubscribed emails | Community
Skip to main content
June 22, 2015
Question

Unsubscribed emails

  • June 22, 2015
  • 1 reply
  • 1483 views

Hi,

I want to take a custom report using api, wherein I want the date, email id and the mail through which the user has unsubscribed from the mailers.

I have checked the marketo API docs but could not find relevant information. Any ideas?

Thanks and Regards,

Bharani 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Level 10
June 22, 2015

You can try the "getLeadActivity" function with parameter "activityFilter->includeAttributes->activityType" having the value "UnsubscribeEmail".

Hope this will help you.

June 23, 2015

Thanks for the responce!

I have already tried that, but the Offset is 0.

Here is the snippet for reference, Let me know if there is any issue in this code.

MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName);

            MktowsPort port = service.getMktowsApiSoapPort();

           

        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

            String text = df.format(new Date());

            String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22);         

            String encryptString = requestTimestamp + marketoUserId ;

           

            SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1");

            Mac mac = Mac.getInstance("HmacSHA1");

            mac.init(secretKey);

            byte[] rawHmac = mac.doFinal(encryptString.getBytes());

            char[] hexChars = Hex.encodeHex(rawHmac);

            String signature = new String(hexChars);

           

  

            AuthenticationHeader header = new AuthenticationHeader();

            header.setMktowsUserId(marketoUserId);

            header.setRequestTimestamp(requestTimestamp);

            header.setRequestSignature(signature);

           

   

            ParamsGetLeadActivity request = new ParamsGetLeadActivity();

            LeadKey key = new LeadKey();

            key.setKeyType(LeadKeyRef.EMAIL);

            key.setKeyValue("t@t.com");

            request.setLeadKey(key);

            ObjectFactory objectFactory = new ObjectFactory();

            JAXBElement<Integer> batchSize = objectFactory.createParamsGetLeadActivityBatchSize(10);

            request.setBatchSize(batchSize);

           

            ActivityTypeFilter atv = new ActivityTypeFilter();

            ArrayOfActivityType aatt = new ArrayOfActivityType();

           

          

            aatt.getActivityTypes().add(ActivityType.UNSUBSCRIBE_EMAIL);

           

            atv.setIncludeTypes(aatt);

            JAXBElement<ActivityTypeFilter> typeFilter = objectFactory.createParamsGetLeadActivityActivityFilter(atv);

            request.setActivityFilter(typeFilter);

           

            SuccessGetLeadActivity result = port.getLeadActivity(request, header);

            JAXBContext context = JAXBContext.newInstance(SuccessGetLeadActivity.class);

            Marshaller m = context.createMarshaller();

            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

            m.marshal(result, System.out);

Level 10
June 23, 2015

As per the WSDL file, Activity type should be "UnsubscribeEmail" not "UNSUBSCRIBE_EMAIL".

Can you try this?