• I added a “Shop” menu item on my blog – it takes to to a POD site where I sell my photos.

    I use Google Analytics on my blog, but I can’t use it to track visits to that POD site. I’d like to know when that “Shop” item gets clicked. I think I could have that link go to a dummy page on my blog, which does nothing but redirect to the POD. I just don’t know how to do it. Could someone give me a start?

    • This topic was modified 2 years, 12 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Setting up a WP page to auto-redirect is kind of a pain. It’d be easier to create a static .html page with a meta refresh tag and necessary GA tags. Have your menu item link to that page. The page won’t look like much since there’s no theme styling. Wouldn’t matter much for a no delay redirect.

    A better solution if you can code JS or jQuery is to install a click event listener for that menu item. On click, prevent default, then execute whatever code the GA tags would normally execute, then redirect directly to the POD location.

    Thread Starter jimh12345

    (@jimh12345)

    Thanks.

    Thread Starter jimh12345

    (@jimh12345)

    Hmmm… maybe this is not so simple.

    I found out how to edit HTACCESS to add a redirect. I created a dummy WP page, pointed my menu item to it, and then, in HTACCESS, redirected it to my POD site. The redirect works, but GA never sees a page access. I know nothing about how GA works or what triggers it, but clearly the target page has to be served before I send the user elsewhere.

    I guess I need some sort of code on my ‘dummy’ page to send the user elsewhere, ideally before the ‘dummy’ page renders.

    Seems like a meta refresh tag might do the trick. But I haven’t yet seen how to add one to my ‘dummy’ page.

    • This reply was modified 2 years, 12 months ago by jimh12345.
    Moderator bcworkz

    (@bcworkz)

    Yeah, .htaccess redirects happen without the dummy page even being accessed, hence no GA triggers. Don’t do that ??

    I’m not 100% sure a meta tag redirect will trigger GA tags. Maybe 85% sure. Worth a try for sure. The required meta tag belongs in the page’s head section, which get’s a little involved on a WP page. It’s why I thought creating a static .html page would be simplest. Such a page is mostly Web circa 1995 ??

    <html>
      <head>
        <title>Redirect to POD</title>
        <meta http-equiv="refresh" content="0" url="https://domain.and/path/to/POD/">
      </head>
      <body>
        You're being taken to POD...
        <!-- Insert your GA tags here -->
      </body>
    </html>

    Place this in a redirect.html file. Place it in the WP installation folder where wp-config.php is. Make a custom link in your menu linking to it.

    Thread Starter jimh12345

    (@jimh12345)

    Yes, with a couple of tweaks, that worked, thanks.

    1995 – ha. Back then I was up-to-date.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I trigger a GA page hit from a menu item?’ is closed to new replies.