AdWords Conversion tracking on a Single Page React App

Webmasters Asked by Rohan Büchner on December 27, 2021


In not familiar with google AdWords at all, and I don’t have access to the AdWords configuration system (whatever it may be). I’m on the dev team who built a food delivery platform. The client has outsourced the marketing aspects to a marketing company.

The application is build in:

  • React
  • Redux
  • Connected-Router
  • Redux-Beacon
  • GTM (for tools like GA, Floodlight, Hotjar etc)

We have a separate auth portal living on a subdomain called, which a user MUST go through at some stage (e.g ordering cant be done without an account)

The marketing team has published pay for ads on google. search for south african mcdonalds delivery

The problem:

Problem Summary:

The marketing team claims that the ads aren’t being picked up as the
source of conversion / sales on the app. From my very limited
understanding it seems that this Ad Context is lost somehow, and by the time the sale is made
the source of the sale is inferred as organic inside GA vs Paid Search (CPC) (see image below) enter image description here

What I’ve seen in my testing:

When clicking on the link in google the ad does append the gclid like below


But when clicking on any other link in the app the url will get replaced with the relevant new url (without preserving the gclid query string)


I have also seen that the following cookies are present on the app, _gcl_aw seems to align to the query string value that was supplied initially via the google ad link.
enter image description here

Other potential relevant info:

  • I have enabled the conversion linker in GTM
  • I have setup subdomain tracking

What am I missing? There doesn’t seem to be a lot of info online with how to setup Google Ads correctly online within the context of a SPA app, and me not knowing marketing well enough & the marketing guys not knowing dev well enough has created some confusion.

One Answer

I came across this blog post.

In there Simo highlights that the issue is to do with the location being updated, this I believe is something intrinsic to SPA apps. His solution of just creating a new property in the dataLayer didn't work for all our application's use cases, as during some workflow of this SPA, we DO leave the single page.

Thus I ended up creating a slightly different implementation of his suggested solution. I ended up persisting the original location in session storage (as it is the most likely to be cleared out when, well.. the session ends.) See code below:

  if(!{{DLV - OriginalLocation}}) { 
    window.dataLayer = window.dataLayer || [];  
    var _ol = document.location.protocol + '//' +  
         document.location.hostname +  
         document.location.pathname +  ;   
    var sessionItem = sessionStorage.getItem('{{Const - OriginalLocation Key}}');
    if(sessionItem) {    
         originalLocation: sessionItem
    } else {
      sessionStorage.setItem("{{Const - OriginalLocation Key}}", _ol);    
        originalLocation: _ol

I then made a variable that gets connected to the GA tracking config.

  var sessionItem = sessionStorage.getItem('{{Const - OriginalLocation Key}}');
  if(sessionItem) {
    return sessionItem;
  return null;

Variations of the fix above (that didn't work).

  • I did try to manually rebuild the original location using the existing _gclid, this did work, but I think it would have causes issues when we start to introduce utm parameters.
  • I tried to make my own custom cookie, but this could result in the cookie persisting a bit too long, and then we could potentially get false ad hits (if the cookie hasn't expired and the user re-visits on the same day via another link)

Answered by Rohan Büchner on December 27, 2021

Add your own answers!

Related Questions

Apache mod_rewrite in .htaccess

1  Asked on November 3, 2021 by simplifixed


Google Verified Reviews for non online services

0  Asked on November 3, 2021 by trebor


Forwarding a subdomain to a Minecraft Server

2  Asked on February 26, 2021 by goodpie


Crafting a regex for mod_rewrite with more than nine parameters

2  Asked on February 20, 2021 by mike-no-longer-here


How Does Google Search Find Pages On Web Site

2  Asked on February 17, 2021 by glez


Mongo Atlas outbound data costs

0  Asked on January 30, 2021 by josh-hansen


How to Remove URLs from Google Search Engine

6  Asked on January 9, 2021 by web-trainings


Is there an alternative to .htaccess?

3  Asked on December 29, 2020 by bob-ortiz


How to de-index pages from google using robots.txt

2  Asked on December 27, 2020 by genadinik


Do CSS libraries like Bootsrap hurt SEO and Google rankings?

1  Asked on December 25, 2020 by kovcs-gergely


cPanel incorrectly identifying remote DNS server type

1  Asked on December 11, 2020 by christopher-h


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir