Is there any way to retrieve a Journey's context data (definitionInstanceId, journeyId) using AMPscript, GTL or SSJS in an email ?


This is a little crazy and I haven't tested it in the context of a Journey, but it should work.

There isn't any journey context data on the list of available personalization strings (https://help.salesforce.com/articleView?id=mc_es_available_personalization_strings.htm&type=5), but what you can get is Job ID.

You can then use the Job ID to look up the TriggererSendDefinitionObjectID from the _Job data view, which you can then use to look up the VersionID in the _JourneyActivity data view, which you can then use to look up data from the _Journey data view.

This will allow you to retrieve any data you need from any of these data views including Journey ID (I'm not sure what definitionInstanceId is). The available fields can be found here:

Here is some sample code to retrieve Journey ID:

    set @tsdid = Lookup("_Job", "TriggererSendDefinitionObjectID", "JobID", jobid)
    set @version_id = Lookup("_JourneyActivity", "VersionID", "JourneyActivityObjectID", @tsdid)
    set @journey_id = Lookup("_Journey", "JourneyID", "VersionID", @version_id)

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.