Intégration de Piwik dans l'iframe
parent
3978fc41c7
commit
b14b81f4d7
|
@ -17,12 +17,21 @@ import About from 'Components/pages/About'
|
|||
import ReactPiwik from 'Components/Tracker'
|
||||
import createHistory from 'history/createBrowserHistory'
|
||||
import Header from 'Components/pages/Header'
|
||||
import { getIframeOption } from '../utils'
|
||||
|
||||
const piwik = new ReactPiwik({
|
||||
url: 'stats.data.gouv.fr',
|
||||
siteId: 39,
|
||||
trackErrors: true
|
||||
})
|
||||
let integratorUrl = getIframeOption('integratorUrl')
|
||||
ReactPiwik.push([
|
||||
'setCustomVariable',
|
||||
1,
|
||||
'urlPartenaire',
|
||||
decodeURIComponent(integratorUrl || 'https://embauche.beta.gouv.fr'),
|
||||
'visit'
|
||||
])
|
||||
|
||||
export default class Layout extends Component {
|
||||
history = createHistory()
|
||||
|
|
|
@ -6,14 +6,11 @@ import reducers from './reducers'
|
|||
import DevTools from './DevTools'
|
||||
import { AppContainer } from 'react-hot-loader'
|
||||
import computeThemeColours from './components/themeColours'
|
||||
import { getIframeOption, getUrl } from './utils'
|
||||
|
||||
let url = window.location.href.toString(),
|
||||
urlColour = url.includes('couleur=')
|
||||
let initialStore = {
|
||||
iframe: url.includes('iframe'),
|
||||
themeColours: computeThemeColours(
|
||||
urlColour && url.split('couleur=')[1].split('&')[0]
|
||||
)
|
||||
iframe: getUrl().includes('iframe'),
|
||||
themeColours: computeThemeColours(getIframeOption('couleur'))
|
||||
}
|
||||
|
||||
let store = createStore(reducers, initialStore, compose(DevTools.instrument()))
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// Get the "couleur" parameter passed to this script
|
||||
let script = document.getElementById('script-simulateur-embauche'),
|
||||
couleur = script.dataset['couleur'],
|
||||
src = script.getAttribute('src')
|
||||
src = script.getAttribute('src'),
|
||||
integratorUrl = encodeURIComponent(window.location.href.toString())
|
||||
|
||||
document.write(`
|
||||
<iframe id="simulateurEmbauche" src="${
|
||||
src.split('dist')[0]
|
||||
}?couleur=${couleur}&iframe" style="border: none; width: 100%; display: block; margin: 0 auto; height: 45em" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>
|
||||
}?couleur=${couleur}&iframe&integratorUrl=${integratorUrl}" style="border: none; width: 100%; display: block; margin: 0 auto; height: 45em" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>
|
||||
`)
|
||||
|
|
|
@ -1 +1,8 @@
|
|||
export let capitalise0 = name => name[0].toUpperCase() + name.slice(1)
|
||||
|
||||
export let getUrl = () => window.location.href.toString()
|
||||
export let getIframeOption = optionName => {
|
||||
let url = getUrl(),
|
||||
hasOption = url.includes(optionName + '=')
|
||||
return hasOption && url.split(optionName + '=')[1].split('&')[0]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue