What do Google Tag Manager, a Facebook Pixel, and a Twitter Pixel all have in common? They all have to be embedded in the Magento header to function properly, and Magento 2 made that just a little bit harder to do.
To embed a custom script in the Magento header, log into the Magento admin and go to Content >> Configuration(Under Design) >> and select “Edit” next to your store view theme. From here, you’ll see a screen that looks something like this –
Click on “HTML Head” and scroll down to the section that says “Scripts & Style Sheets”. From here, embed your code, and save.
Once that’s done, you may need to flush the Magento cache to get it to show up on the frontend. To do that, navigate to System >> Cache Management(under Tools). There you can select all, and then hit “Submit” next to the “Refresh” drop-down.