add_action('gform_after_submission', 'push_gf_purchase_to_datalayer', 10, 2); function push_gf_purchase_to_datalayer($entry, $form) { $product_name = ''; $total_value = 0;foreach ($form['fields'] as $field) { $field_id = $field->id; $field_value = rgar($entry, (string) $field_id);// Automatically detect Product field if ($field->type === 'product' || stripos($field->label, 'product') !== false) { $product_name = $field_value; }// Automatically detect Total field if ($field->type === 'total' || stripos($field->label, 'total') !== false) { $total_value = $field_value; } }?> id; $field_value = rgar($entry, (string) $field_id);// Automatically detect Product field if ($field->type === 'product' || stripos($field->label, 'product') !== false) { $product_name = $field_value; }// Automatically detect Total field if ($field->type === 'total' || stripos($field->label, 'total') !== false) { $total_value = $field_value; } }?> id; $field_value = rgar($entry, (string) $field_id);// Automatically detect Product field if ($field->type === 'product' || stripos($field->label, 'product') !== false) { $product_name = $field_value; }// Automatically detect Total field if ($field->type === 'total' || stripos($field->label, 'total') !== false) { $total_value = $field_value; } }?>
loading...

Shop

In a life-Threatening Emergency Dial 999 or 112