Add affiliate code to backing track pages
This commit is contained in:
parent
b7732c11f8
commit
39dfbadbd8
|
|
@ -1,4 +1,4 @@
|
|||
import React, {useContext} from "react";
|
||||
import React, {useContext, useEffect} from "react";
|
||||
import { BrowserRouter as Router, ReactDOM } from "react-router-dom";
|
||||
|
||||
import JKJamTracksArtistLandingBody from "./JKJamTracksArtistLandingBody";
|
||||
|
|
@ -22,6 +22,17 @@ const ArtistTemplatePage = ({ original_artist_slug, artist, songs}) => {
|
|||
|
||||
const paddingClass = greaterThan.sm ? "px-6" : "px-1";
|
||||
|
||||
useEffect(() => {
|
||||
//see if there is affiliate in query string and save it as cookie
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const affiliate = urlParams.get('affiliate');
|
||||
const maxAge = 24 * 3600; // 1 day
|
||||
if (affiliate) {
|
||||
console.log(`Setting affiliate ${affiliate} cookie for artist landing page ${process.env.REACT_APP_COOKIE_DOMAIN}`);
|
||||
document.cookie = `affiliate_visitor=${affiliate}; path=/; max-age=${maxAge}; domain=${process.env.REACT_APP_COOKIE_DOMAIN}`;
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
<Router location={location} context={{}}>
|
||||
<div className={isFluid ? 'container-fluid' : 'container'}>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, {useContext} from "react";
|
||||
import React, {useContext, useEffect} from "react";
|
||||
import { BrowserRouter as Router, ReactDOM } from "react-router-dom";
|
||||
|
||||
import JKJamTracksLandingBody from "./JKJamTracksLandingBody";
|
||||
|
|
@ -21,9 +21,19 @@ const TemplatePage = ({ id, plan_code, slug, artist, song, location}) => {
|
|||
|
||||
const { greaterThan } = useResponsive();
|
||||
|
||||
|
||||
const paddingClass = greaterThan.sm ? "px-6" : "px-1";
|
||||
|
||||
useEffect(() => {
|
||||
//see if there is affiliate in query string and save it as cookie
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const affiliate = urlParams.get('affiliate');
|
||||
const maxAge = 24 * 3600; // 1 day
|
||||
if (affiliate) {
|
||||
console.log(`Setting affiliate ${affiliate} cookie for artist landing page ${process.env.REACT_APP_COOKIE_DOMAIN}`);
|
||||
document.cookie = `affiliate_visitor=${affiliate}; path=/; max-age=${maxAge}; domain=${process.env.REACT_APP_COOKIE_DOMAIN}`;
|
||||
}
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
<Router location={location} context={{}}>
|
||||
<div className={isFluid ? 'container-fluid' : 'container'}>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const Layout = () => {
|
|||
//see if there is affiliate in query string and save it as cookie
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const affiliate = urlParams.get('affiliate');
|
||||
const maxAge = 2592000; // 30 days
|
||||
const maxAge = 24 * 3600; // 1 day
|
||||
if (affiliate) {
|
||||
document.cookie = `affiliate_visitor=${affiliate}; path=/; max-age=${maxAge}; domain=${process.env.REACT_APP_COOKIE_DOMAIN}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue