Getting Started
Project setup
Install the package
yarn add google-fls # or npm i google-flsfls_global is the function used to generate the Google tag. Below we can see how the function is composed:
fls_global(isCookiesFriendly, config, activitySettings, customVariables)Let's start with a basic setup, firstable we have to import React and useEffect to make all possible.
After that we can use fls_global inside useEffect to load the function at the first load page.
import React, {useEffect} from 'react'import fls_global from 'google-fls' // import google-flsfunction App() { useEffect(() => { fls_global(true, // isCookiesFriendly true or false { format: 'global', // supported format: global, iframe and image advertiser_id: 8384813 // Advertiser ID }, { type: 'test', // Type cat: 'test' // Cat }) }, []) return ( <> Test Application </> )}export default App;Now, let's see as the function is build.
| Value | Type | Required | Description |
|---|---|---|---|
| isCookiesFriendly | Boolen | True | Used to activate o deactivate Google's cookies. If you set it false the tag will not trigger. |
| config | Object | True | Set-up yor format and advertiser_id |
| activitySettings | Object | True | Set-up yor type and cat |
| customVariables | Object | False | Set-up yor custom variables here |
format supported are: global, iframe and image.