Classifications

Home / Classifications
In this use case we are going to perform real time classifications on incoming data. This is particularly useful for tagging like solutions which generate a lot of reports out of the box but are very dependent on the input. In this case we’re going to use a separate concept to extend the input values. Additionally we will use the output plugin to make the data available in the page again.

The initial code is:

concept Global {
	match '*'

	val page = `"homepage"`
	val campaign = `"12345"`

	flow (in)
	=> call[`Classification`]
	=> out

	plugin output[flowName = 'in'] `
		console.log("campaign code: "+campaign);
		console.log("campaign name: "+campaign_name);
		dataLayer = [{
			'campaign': campaign,
			'campaign_name': campaign_name
		}];
	`
}

@groovy

concept Classification {
	flow
	=> if[`campaign != NULL`] (nocampaign)
	=> code[campaign_name=`"Marketing Spring campaign"`] (goout)

	flow(nocampaign)
	=> code[campaign_name=`"no campaign"`] (goout)

	flow(goout)
	=> out
}

When looking at the specific code, we can see the following structure

  • In this example the campaign is defined hard coded.
  • Processing starts with the “in” flow. Normally named flows are only started when they get called. However specifically for the output plugin, the flow referred to is always started. This means that the processing in the “in” flow is executed before the client side code of the output plugin is executed. The output plugin is called right when the “out” flow element is called in the flow, adding this flow element is necessary for the output plugin to work.
  • The flow in the Global concept uses the call flow element to execute the unnamed flows in the Classfication concept
  • The Classification concept can then use the fields of the Global concept. In this case the campaign field can be used to add a campaign_name to the data tuple. The “out” flow element is used to continue the original flow which used the call flow element
  • The Classification concept always provides the value “Marketing Spring campaign”, irrelevant of the actual value of the campaign field.
  • The output plugin is executed with both the “campaign” and “campaign_name” field available. In the output plugin’s code all fields are available as variable. Apart from printing the values in the Javascript console, the fields are also added to a dataLayer object. This kind of object, containing data of the current interactions is typically used in tagging/tag management like solutions.

Additional assigment

  1. Change the Classification concept such that specifically campaign “67890” will be classified to “Summer Marketing Campaign”. Use a server side look up list which contains for each campaign, the campaign name.
  2. Change the definition of the campaign field to collect the query parameter “cmp” from the URL.
  3. Change the Classification concept such that a database table is queried containing the campaign name