# Automated injection

This type of injection allows for the automated and intelligent integration of ad slots according to page templates and some publisher's selectors.&#x20;

The available parameters provide flexibility for injection.&#x20;

* `.setInjectedSelector`: Defines the page element for injection.
* `.setInjectedPosition`: Defines the injection position in relation to the element `.setInjectedSelector`. Four values available between `beforebegin`, `afterbegin`, `beforeend`, `afterend.`
* `.setInjectedMaxRepetition`: Enables limiting the injection occurrences on the page.
* `.setInjectedStyle`: Applies a CSS style to the injected ad slot.
* `.setInjectedLabel`: Names an ad placement. This name will be incremented at each injection, allowing detailed and proper monitoring. For example: "incontent1" then "incontent2" then "incontent3".
* `.activateInjectedIncrementalAdUnitId` : Enables the activation of the auto-creation of incremental GAM ad units. This is optional and can be useful depending on your inventory structure to better monitor each ad unit's performance.
* `.setInjectedIncrementalTargeting` : Enables attributing a specific value to each injected ad unit. It must replace `.setTargeting` in case of an identical key in order to avoid duplicate entries.

Here is a code example without the function `.activateInjectedIncrementalAdUnitId` : &#x20;

```
n360Ad.defineInjectedSlot('/your_GAM_network_ID/your_GAM_adunit',[[300,250],['fluid']],'div-3')
  .setNexx360TagId('ENTER YOUR PLACEMENT ID')
  .setInjectedSelector('h3')
  .setInjectedPosition('beforebegin')
  .setInjectedMaxRepetition(4)
  .setInjectedStyle('text-align:center; margin-bottom: 20px;')
  .setInjectedLabel('adunit', 'incontent_ad')
  .setTargeting('adunit', 'incontent_ad')
  .setTargeting('position', 'mtf');
```

Here is a code example with the function `.activateInjectedIncrementalAdUnitId` : &#x20;

```
n360Ad.defineInjectedSlot('/your_GAM_network_ID/your_GAM_adunit',[[300,250],['fluid']],'div-3')
  .setNexx360TagId('ENTER YOUR PLACEMENT ID')
  .setInjectedSelector('h3')
  .setInjectedPosition('beforebegin')
  .setInjectedMaxRepetition(4)
  .setInjectedStyle('text-align:center; margin-bottom: 20px;')
  .setInjectedLabel('adunit', 'incontent_ad')
  .activateInjectedIncrementalAdUnitId()
  .setInjectedIncrementalTargeting('adunit', 'incontent_ad-')
  .setTargeting('position', 'mtf');
```
