Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

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

Open
AndreyDrabovich opened this issue Jun 13, 2022 · 1 comment

Comments

@AndreyDrabovich
Copy link

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
Copy link

dtsnyder commented Jan 24, 2023

A couple of quick solutions would be:

  • Find the Object IDs you want to report on in the Email Studio tracking tab (you'll need to expand the menu on the left for Journey Builder tracking). Then use these IDs as your search filter instead of EventDate.
  • Schedule a query of the Journey and Clicks data views through automation studio to build a data extension with exactly the fields and level of granularity you need for your report. At that point your python code would be as simple as retrieving all of the rows from your reporting DE and building the report front end.

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants