> For the complete documentation index, see [llms.txt](https://developer.gravityfield.ai/lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gravityfield.ai/lang/en/implementation/client-side-integration/1.-gravity-field-script.md).

# 1. Gravity Field Script

### 1. Implementing preconnect, prefetch & core.js scripts

On every site page in the `<head>` section:

```jsx
<link rel="preconnect" href="//cdn-01.gravityfield.ai">
<link rel="preconnect" href="//evs-01.gravityfield.ai">
<link rel="dns-prefetch" href="//cdn-01.gravityfield.ai">
<link rel="dns-prefetch" href="//evs-01.gravityfield.ai">
```

Additionally, on every site page in the `<head>` section core.js script must be implemented:

```jsx
<script type="text/javascript" src="//cdn-01.gravityfield.ai/core/core.js"></script>
```

### 2. Implementing GF, Section ID, Page Context variables

Each page must declare a GF variable. It is declared within a separate script consisting of three parts:

```javascript
<script>
window.GF = window.GF || {}; 
GF.section = "111aaa222bbb"; // Section ID, string
GF.pageContext = { type: "PAGETYPE", data: [] }; // PAGETYPE and an empty array just as an example
</script>
```

1. GF variable itself;
2. `GF.section` - unique section ID which must be of **string** type;
3. `GF.pageContext` - variable passing the information about the page context and its description. In the Page Context you can  pass a localization parameter `lng`. You can use `lng` in the case that your site/app is available in more than one language/region and personalization campaigns need to adjust content according to the language/region. You can also use this parameter if there are different product attributes (price/discount amount, etc) in different regions/cities.\
   More about page context: [2. Page Context](/lang/en/implementation/client-side-integration/2.-page-context.md)

More about scripts: [Gravity Field Scripts Workflow](/lang/en/implementation/client-side-integration/1.-gravity-field-script/scripts.md)

## Appendix

Example of correctly installed scripts on the shopping cart page:

{% code overflow="wrap" %}

```javascript
<link rel="preconnect" href="//cdn-01.gravityfield.ai">
<link rel="preconnect" href="//evs-01.gravityfield.ai">
<link rel="dns-prefetch" href="//cdn-01.gravityfield.ai">
<link rel="dns-prefetch" href="//evs-01.gravityfield.ai">

<script>
window.GF = window.GF || {}; 
GF.section = "6315dda2f1c33ba4cd04655b";
GF.pageContext = {type: "CART",data: ["XD-154","DL-5874","TN-15","QSD-1581","XD-15"]};
</script>

<script type="text/javascript" src="//cdn-01.gravityfield.ai/core/core.js"></script>
```

{% endcode %}

Script connection order:

1. Preconnect and prefetch;
2. Declaring the GF variable and specifying a Page Context;
3. Core.js.
