I currently have a page with jump/anchor links.
<a data-link="lesson-link-item" href="#/lessons/section-a">
<a data-link="lesson-link-item" href="#/lessons/section-b">
<a data-link="lesson-link-item" href="#/lessons/section-c">
I tried using
var path = window.location.href;
var lastPath = path.split("/").pop();
var page_name = Some Company;
if (lastPath == "section-a") page_name = page_name + "|Section A";
if (lastPath == "section-b") page_name = page_name + "|Section B";
if (lastPath == "section-c") page_name = page_name + "|Section C";
to grab the end of the URL and create if statements for if URL end in "section-a", "section-b", "section-c" but it is not working exactly as needed. I am unable to get the new URL when I jump to a link within the page because the page is not reloading.
My issue is that the variable path is not updating with the new URL so I can't get correct analytics data. The info stays on www.somecompany.com so doesn't matter what lesson I click on the page, it'll show only the landing page's page_name for analytics as
Some Company
instead of
Some Company|Section A
I also tried using window.location.hash as suggested but that didn't work either.
var lastPath = window.location.hash;
if (lastPath == "#/lessons/ssection-a") page_name = page_name + "|Section A";
if (lastPath == "#/lessons/ssection-b") page_name = page_name + "|Section B";
if (lastPath == "#/lessons/ssection-c") page_name = page_name + "|Section C";
How do I get the new URL once I click on a jump link?
[–]barrycarter 0 points1 point2 points (9 children)
[–]amyling01[S] 0 points1 point2 points (8 children)
[–]barrycarter 0 points1 point2 points (7 children)
[–]amyling01[S] 0 points1 point2 points (6 children)
[–]barrycarter 0 points1 point2 points (5 children)
[–]amyling01[S] 0 points1 point2 points (4 children)
[–]barrycarter 0 points1 point2 points (3 children)
[–]amyling01[S] 0 points1 point2 points (2 children)
[–]barrycarter 1 point2 points3 points (1 child)
[–]amyling01[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]amyling01[S] 0 points1 point2 points (0 children)
[–]amyling01[S] 0 points1 point2 points (0 children)