Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Segment IO in Chrome Extension

I can't seem to get Segment to work despite following these instructions: https://segment.com/docs/platforms/chrome-extension/

When I run analytics.track, I don't see any network requests for the tracking pixels but I don't see any error either. The analytics object exists, but it doesn't seem to do anything.

It's important to note here that I'd like to run Segment from the context of the page. My extension injects new DOM elements and CSS styles into the webpage and I want to track the user's interactions with these elements. So Segment is not running in the context of the extension at all. It's injected into the page's head as a script.

like image 560
user438293456 Avatar asked Jan 12 '15 22:01

user438293456


People also ask

Can you do a Find and Replace in Chrome?

Find and Replace for Google Chrome Using Find and Replace is pretty straightforward. Go to the page you want to find and replace text in, press the keyboard shortcut Ctrl + Shift + F and enter the text you want to find into the top box. Next, fill in the “Replace with” field and click “Replace” or “Replace All.”

What is segment in browser?

Segment is a customer data platform (CDP) that helps companies harness first-party customer data. The recent browser changes fully align with Segment's privacy stance.

What cookies does Segment use?

Segment gives the example of IntoTheGloss.com, the blog and community web site of cosmetics brand Glossier. When visitors go to the blog/community site, they receive a first-party IntoTheGloss.com cookie. And when they go to the brand's main site, Glossier.com, they get another first-party cookie for that domain.


1 Answers

Steven here from Segment. We recommend loading analytics.js on a background page, so as not to interfere with the analytics tools that have already been loaded onto the page. In either case, you would do the following:

  1. Create a file called snippet.js with the analytics.js snippet inside it.

  2. Inject the file onto the current page:

    chrome.tabs.executeScript(null, {file: 'snippet.js'});

like image 158
Steven Miller Avatar answered Oct 01 '22 22:10

Steven Miller