How to create a chrome webRequest to validate response code

35 Views Asked by At

I want to check if my Linkedin Pixel tag is installed properly inside my webpages.

To validate, I would need to get a 302 response when the tag is fired.

Trying to create a chrome extension that could perform this validation.

    chrome.webRequest.onSendHeaders.addListener(
  (e) => {
    console.log(e);
  },

  {
    urls: ["https://px.ads.linkedin.com/*"],
  }
);

--console.log object--

 {documentId: 'E3A1D48B4697AC34E10A4D2A888CC8A9', documentLifecycle: 'active', frameId: 0, frameType: 'outermost_frame', initiator: 'https://www.theb2bhouse.com', …}
documentId: "E3A1D48B4697AC34E10A4D2A888CC8A9"
documentLifecycle: "active"
frameId: 0
frameType: "outermost_frame"
initiator: "https://www.theb2bhouse.com"
method: "GET"
parentFrameId: -1
requestId: "2395"
tabId: 2
timeStamp: 1652447005855.711
type: "image"
url: "https://px.ads.linkedin.com/collect?v=2&fmt=js&pid=2742940&time=1652447005855&url=https%3A%2F%2Fwww.theb2bhouse.com%2F"
[[Prototype]]: Object

Does anyone know how to send a webRequest to check if this above details got back a 302-redirect response?

On my inspect -> network request, I could see that the tag is fired correctly and recieved a response code of 302. Yet, I find the correct method to do the validation on webRequest.

0

There are 0 best solutions below