Purchase the extension on the magento marketplace. Don’t worry the extension is free and you won’t need any payment details. You can find the extension here - https://marketplace.magento.com/metrilo-analytics-magento2-extension.html
In order to make the purchase you will need an account on the Marketplace.
In your Magento 2 installation folder run the following command:
composer require metrilo/analytics-magento2-extension
If all went well you will see something like:
In case you get asked for authentication:
Use the access keys from the marketplace profile you used in Step 1. They keys can be found on this page: https://marketplace.magento.com/customer/accessKeys/
The public key is the username
The private key is the password
In case you get a message about missing extension:
Make sure that you are using the correct credentials for authenticating in the marketplace. The credentials are sometimes cached in a file called auth.json in the project root or in the user root directory ~/.composer/auth.json.
Now that the plugin is successfully installed run:
$ bin/magento setup:upgrade
Configure the plugin by going to "Store" > "Configuration" > "Metrilo" > click "Analytics".
You can take the credentials from the Settings/Installation page of your Metrilo project.
Clear any caches you might have to make sure that the metrilo code appears on all of your pages.
$ bin/magento cache:flush