Step 1: Create a Data Layer Variable
First, create a Data Layer Variable to store the current page’s URL:- Variable Name:
DLV - originalLocation
- Data Layer Variable Name:
originalLocation
Step 2: Create a Custom HTML Tag
Set up a Custom HTML tag to save the current page location to the Data Layer VariableoriginalLocation
.
- Tag Name:
Save originalLocation
- Tag Type: Custom HTML
- Tag Configuration:
Step 3: Set Up Tag Sequencing
Ensure the “Save originalLocation” tag fires before the “Dema | Page view” tag:- Navigate to the “Dema | Page view” tag in GTM.
- Go to Advanced Settings > Tag Sequencing.
- Enable the option “Fire a tag before Dema | Page view fires”.
- Select “Save originalLocation” as the setup tag.
Step 4: Modify the Page View Script
Modify your existing page view script to include theDLV - originalLocation
variable. This ensures that the URL of the previously visited page is sent along with the page view event to your tracking script.
Script Modification
Add the Data Layer VariableDLV - originalLocation
as an additional argument in your Dema page view function call: