public function FeatureContext::createGoals in Acquia Lift Connector 7.2
@Given /^goals:$/
Requires each row to have at least:
- action_name: The machine_name for the goal.
- agent: The campagin for the goal
- label: The display name for the goal if it does not a pre-existing visitor action.
Optional values:
- plugin: The type of goal, defaults to page.
- event: The event on for the type of goal, defaults to views.
- pages: The pages to limit for the goal, defaults to ''.
- value: The value for the goal, defaults to 1.
File
- behat-tests/
features/ bootstrap/ FeatureContext.php, line 230
Class
- FeatureContext
- Defines application features from the specific context.
Code
public function createGoals(TableNode $goalsTable) {
foreach ($goalsTable
->getHash() as $goalHash) {
$goal = (object) $goalHash;
$goal_value = isset($goal->value) ? $goal->value : 1;
$actions = visitor_actions_get_actions();
if (!isset($actions[$goal->action_name])) {
$action = array(
'label' => $goal->label,
'machine_name' => $goal->action_name,
'plugin' => isset($goal->plugin) ? $goal->plugin : 'page',
'client_side' => 0,
'identifier' => '',
'event' => isset($goal->event) ? $goal->event : 'views',
'pages' => isset($goal->pages) ? $goal->pages : '',
'data' => array(),
'limited_use' => 1,
);
visitor_actions_save_action($action);
}
personalize_goal_save($goal->agent, $goal->action_name, $goal_value);
}
}