# Set up the web trackers
> Install and initialize the JavaScript or Browser tracker with customizable configuration options.
> Source: https://docs.snowplow.io/docs/sources/web-trackers/tracker-setup/
> Documentation index: https://docs.snowplow.io/llms.txt

**JavaScript (tag):**

There are two distributions of the JavaScript Tracker:

| Distribution | Size (minified + gzipped) | Default distribution | Best for                                                 | Plugins included? |
| ------------ | ------------------------- | -------------------- | -------------------------------------------------------- | ----------------- |
| `sp.js`      | \~25 KB                   | ✅                    | Quick start with the a range of common tracking features | ✅                 |
| `sp.lite.js` | \~18 KB                   | ❌                    | Smaller file size and core tracking only                 | ❌                 |

The `sp.js` distribution doesn't include all available plugins. See the [plugins](/docs/sources/web-trackers/plugins/) page for full details on which are included.

Use the following tag on your page to load `sp.js`:

```javascript
<script type="text/javascript" async=1>
;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","{{URL to sp.js}}","snowplow"));
</script>
```

We recommend self hosting `sp.js` by following our [self hosting](/docs/sources/web-trackers/tracker-setup/hosting-the-javascript-tracker/) guides. All tracker versions are available on [GitHub](https://github.com/snowplow/snowplow-javascript-tracker/releases).

We also recommend renaming `sp.js` as this filename is commonly blocked by adblockers. Renaming to a random string will help ensure the JavaScript Tracker is loaded as expected.

As well as loading the JavaScript Tracker, this tag creates a global function called `snowplow` which you use to access the Tracker. The rest of the documentation will assume that the function is called `snowplow`, but you can replace the string with the function name of your choice.

If you're running multiple JavaScript Trackers on the same page, you can avoid conflicts by specifying different function names for each tracker.

> **Info: Local testing**
>
> If you're testing by opening your HTML file directly from your filesystem, e.g. `file:///home/joe/test.html`, protocol-relative URLs like `//cdn.example.com/sp.js` won't load. Use a local server or specify the full URL with `http://` or `https://`.

Once the tracker is loaded via the tag, you can move on to initializing the tracker.

**Browser (npm):**

Getting started with sending events using the Browser Tracker will be familiar for anyone who is used to installing npm packages into their web apps and is designed to work with frameworks such as React, Angular and Vue.

- Install the `@snowplow/browser-tracker` package using your preferred package manager

  - `npm install @snowplow/browser-tracker`
  - `yarn add @snowplow/browser-tracker`
  - `pnpm add @snowplow/browser-tracker`

- You can then import this library into your application

```javascript
import { newTracker, trackPageView } from '@snowplow/browser-tracker';
```

- Configure an instance of the tracker by calling `newTracker(...)` with your desired properties. This will create a module level instance of your tracker. You don't need to keep a reference to it.

```javascript
newTracker('sp1', '{{collector_url}}', {
  appId: 'my-app-id',
  plugins: [ ],
});
```

- Then you can use the track methods to send some events. You can send a Page View event to all initialised trackers with just:

```javascript
trackPageView();
```

***
