0

I have the requirement on our Drupal 7 site where if we have a single node we need to be able to have multiple url paths to reach that node.

For instance lets say we have a node with id 1234 Currently we can create an alias for it: example.com/my-custom-alias

and I can go to example.com/admin/config/search/path/add and add a second url for this node with id 1234: example.com/differenturl/my-custom-alias

but when I try to go to: example.com/my-custom-alias

the browser redirects the page to: example.com/differenturl/my-custom-alias

What I need is for both urls to resolve to the the same node and for the url to not change (or be redirected).

This is because we use Google Analytics and we need to know from which part of our example.com site our node/1234 is being accessed from.

Currently the only thing that Google Analytics will track is: example.com/differenturl/my-custom-alias

and won't track: example.com/my-custom-alias

Does anyone know how I can achieve this?

  • 2
    Normally you'd track this by some URL query parameter. Like https://example.com/some-alias?custom-parameter=twitter&other-parameter=december-campaign for example. – leymannx Dec 5 '19 at 23:29
  • 1
    Otherwise Google will be pretty angry on you for providing duplicate content. – leymannx Dec 5 '19 at 23:34
  • 2
    agree with leymanxx. you can add anything to your URL as a custom parameter, it will show the same page and analytics will pick it up as a different page unless you remove those parameters in the view. i.e. en.wikipedia.org/wiki/Inventory and en.wikipedia.org/wiki/Inventory?jhvjbjhefbhjbjf is the same page but will show up as unique in analytics – Rick Harington Dec 6 '19 at 9:24
1

Decided to solve the issue by adding URL query parameter to designate where the particular page was coming from as per suggestion of leymannx and Rick Harinton.

Thanks for all your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.