When clicking on any site when clicking on a link with target="_blank" ... In the program, the page opens in the same window, but the Google Analytics counters see such a transition is not correct without a referrer. It seems like a direct approach. Tested with their sites also .. If in a normal browser I go with target="_blank" then the referrer is visible transition and displays the site from which the transition was. If I move from the program with the code shown here, it goes as a direct approach. Help to understand. Thank you!
class WebEnginePage(QWebEnginePage):
def createWindow(self, _type):
page = WebEnginePage(self)
page.urlChanged.connect(self.on_url_changed)
return page
@pyqtSlot(QUrl)
def on_url_changed(self, url):
page = self.sender()
self.setUrl(url)
page.deleteLater()
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.browser = QWebEngineView()
page = WebEnginePage(self.browser)
self.browser.setPage(page)
self.browser.setUrl(QUrl("http://google.com"))
self.browser.urlChanged.connect(self.update_urlbar)
self.browser.loadFinished.connect(self.update_title)
self.setCentralWidget(self.browser)
def update_title(self):
title = self.browser.page().title()
self.setWindowTitle("%s - prog" % title)
def update_urlbar(self, q):
self.urlbar.setText(q.toString())
self.urlbar.setCursorPosition(0)