# Advanced Configuration

## Customising Integration Triggers

In some cases, there may be a requirement to customise which traffic triggers the Netacea integration within a single Fastly service traffic.

This could be for various reasons, including:

* Multiple domains exist on the same Fastly service, and Netacea protect each domain with a separate set of Datastream models
* Multiple domains exist on the same Fastly service, but Netacea only protect a subset of those domains
* The Netacea Integration needs to be limited to trigger and protect a limited set of pathways
* The Netacea Integration needs to [behave differently](https://docs.netacea.com/overview/integration-modes) based on certain criteria

To support customised triggers, follow the steps outlined below.

{% hint style="warning" %}
Do not complete this configuration without discussing the steps with the Netacea team
{% endhint %}

## Update the Netacea Dictionary

Update the Netacea dictionary configured as part of the standard [Installation and Configuration Guide](https://docs.netacea.com/netacea-plugin-information/fastly-magento/installation-and-configuration/..#create-an-empty-dictionary). The dictionary must be updated to include the variables and values normally set in the [Netacea Module](https://docs.netacea.com/netacea-plugin-information/fastly-magento/installation-and-configuration/..#apply-customer-keys-to-the-module).

<figure><img src="https://3359534748-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KQH1bDl0sVMvZgHUjkC%2Fuploads%2Fgit-blob-eb65ad33ebb0f8f1b5f89ec0ba1f265d35d86a1e%2Fimage%20(104).png?alt=media" alt=""><figcaption></figcaption></figure>

The Netacea module fields should be set to blank:

<figure><img src="https://3359534748-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KQH1bDl0sVMvZgHUjkC%2Fuploads%2Fgit-blob-0644bb0ac8cefcd88072c61b6f54687eb96f13c0%2Fimage%20(102).png?alt=media" alt=""><figcaption></figcaption></figure>

## Create & Customise the recv\_configure.vcl

Lastly, the recv\_configure.vcl will need to be created to include the conditional statements that define how the Netacea integration triggers:

* Cause the integration to trigger on a subset of requests made on the Fastly service.
* Define which Datastream credentials are used when traffic triggers the integration on the Fastly Service.

Navigate to Stores → Configuration → Advanced → System → Full Page Cache → Fastly Configuration → Custom VCL Snippets and click "Create".

<figure><img src="https://3359534748-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8KQH1bDl0sVMvZgHUjkC%2Fuploads%2Fgit-blob-637be77c061c98e7dbed7db4802fdef3cd5aabbb%2Fimage%20(106).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Selective trigger

The following example will cause the integration to trigger on login specific request pathways.

<pre><code>set req.http.x-netacea:edge_config_key_prefix = "";
declare local var.should_run_netacea BOOL;

set var.should_run_netacea = false;

# Must enable Netacea on the following paths if using captcha:
if (!var.should_run_netacea) {
  if (req.url.path ~ "^/AtaVerifyCaptcha|^\/Mitigations\/") {
    set var.should_run_netacea = true;
  }
}

<strong>if (!var.should_run_netacea) {
</strong>  if (req.url.path ~ "\/.*\/(login)\/") {
    set var.should_run_netacea = true;
  }
}

if (var.should_run_netacea) {
  call netacea_check_req;
}
</code></pre>

#### Splitting trigger

The following example will cause the integration to use different Datastream credentials based on the request's associated domain.

```
declare local var.should_run_netacea BOOL;
set var.should_run_netacea = false;

# Must enable Netacea on the following paths if using captcha:
if (!var.should_run_netacea) {
  if (req.url.path ~ "^/AtaVerifyCaptcha|^\/Mitigations\/") {
    set var.should_run_netacea = true;
  }
}

#
if (!var.should_run_netacea) {
  if (req.http.host ~ "example.com") {
    set var.should_run_netacea = true;
    set req.http.x-netacea:edge_config_key_prefix = "dsA_";
  }
}

if (!var.should_run_netacea) {
  if (req.http.host ~ "example2.com") {
    set var.should_run_netacea = true;
    set req.http.x-netacea:edge_config_key_prefix = "dsB_";
  }
}

if (var.should_run_netacea) {
  call netacea_check_req;
}

```

## Update Log Shipping

Lastly, you may need to update your Shipping configuration based on requirements defined by the Netacea Team.
