salesforce-marketingcloud / FuelSDK-Python

FuelSDK for python
Other
127 stars 191 forks source link

[Enhancement] Get unique clicks from specific journey using Python SDK #141

Open AndreyDrabovich opened 2 years ago

AndreyDrabovich commented 2 years ago

I need to get unique clicks and opens from specific journey from Salesforce Marketing Cloud.

I use Python SDK and get all possible clicks from account. Here is my code:

myClient = FuelSDK.ET_Client(False, False,
    {'clientid': clientid, 
    'clientsecret':clientsecret,
    'useOAuth2Authentication': 'True',
    'authenticationurl': auth_base_url,
    'applicationType': 'server',
    'baseapiurl': rest_url,
    'soapendpoint': soap_url})

since = (date.today() - timedelta(10)).strftime('%Y-%m-%d')
event = FuelSDK.ET_ClickEvent()
event.auth_stub = myClient
event.props = [
    "ID", "ObjectID", "PartnerKey","CreatedDate","ModifiedDate",
    "Client.ID","SendID","SubscriberKey","EventDate","EventType",
    "TriggeredSendDefinitionObjectID","BatchID","URLID","URL"
    ]
search_filter = {'Property': 'EventDate', 'SimpleOperator': 'greaterThan', 'DateValue': str(since)}
event.search_filter = search_filter
response = event.get()

result_list = response.results

while response.more_results:
    response = event.getMoreResults()
    result_list.extend(response.results)

Do you have any ideas how I can filter this result? Or may be there are any other ways to get unique clicks with python?

dtsnyder commented 1 year ago

A couple of quick solutions would be:

For a few ad-hoc reports the first approach should be fine but for anything automated/ongoing I'd suggest the second approach to make it more maintainable.