How to implement Usercentrics in Angular
...
For the Angular Implementation, you will need to install Angular CLI globally on your machine. You can install it, by running it on the terminal:
Code Block | ||
---|---|---|
| ||
npm install -g @angular/cli |
(we assume that you have node.js installed on your computer)
To create a new workspace and an initial application, you will need to run:
Code Block |
---|
ng new angular |
Navigate to the folder in the terminal by using cd angular
, and then run the following command to launch the app:
Code Block | ||
---|---|---|
| ||
ng serve --open |
Assuming that you have an Angular App already working, you can implement our Usercentrics Scripts in the following way:
CMPv1 Implementation
Open
index.html
in your app directoryAdd the following script to the <head> tag:
Code Block language html //Change 'xxxxxx' to your settingsID <script> window.usercentrics = { settingsId: 'xxxxxx' }; window["usercentrics"] = { paths: { "bundle": "https://app.usercentrics.eu/latest/bundle.js", }, settingsIds: 'xxxxxx', settingsVersionOverwrite: 'preview', }; </script>
Then save and the localhost will reload and load into the page, the bundle.js.
CMPv2 Implementation
Open
index.html
in your app directoryAdd the following script to the <head> tag:
Then save and the localhost will reload and load into the page, the bundle.jsCode Block //Change 'xxxxxx' to your settingsID //Normal Bundle <script id="usercentrics-cmp" data-settings-id="XXXXXXXX" src="https://app.usercentrics.eu/browser-ui/latest/loader.js" async></script>
Do you need further help?
...