Skip to main content
Level 3
Nov 17, 2026 4:08 PM UTC
Solved

getQueryParams not working on SPAs

 Hi everyone,

I’m trying to use the getQueryParams plugin to get a query string param on an SPA. The URL updates on the SPA change and includes the query string. I can grab the whole query string into Adobe Analytics using window.location.search. However, getQueryParams returns empty. On full page load, the query string param is passed as expected, but not on SPA.

Does anyone have any experience of using getQueryParams on a SPA. I know the plugin is pretty old. Is it designed to work on SPA or is it full page load only?

    SrividyaVenkat
    SrividyaVenkatAccepted solution
    Level 3
    Nov 18, 2026 6:07 AM UTC

    Hi ​@tcrewes1 

    The getQueryParam plugin is not inherently restricted to full-page loads. However, it is not SPA-aware either. It reads the query string from the URL at the time it is executed.

    In an SPA, URL changes through history.pushState() or history.replaceState() do not trigger a full-page reload. Therefore, the plugin will not automatically execute again to capture the updated query parameters.

    Try using the below flow maybe it could be of an help

    1. Create a Data Element using Core → Query String Parameter and specify the required parameter (e.g., utm_source).

    2. Create a rule with Core → History Change as the event to detect SPA route changes.

    3. Configure an Adobe Analytics action to set the required eVar using the Query String Parameter data element.

    4. Trigger the Track State / Send Beacon action after setting the variables.

    If the SPA uses custom routing, you can alternatively use a custom event triggered by the application after the URL is updated.

    One important point is ensure that the data element is evaluated after the URL changes and that its storage duration does not cause stale values to be returned.

     

    6 replies

    SrividyaVenkat
    SrividyaVenkatAccepted solution
    Level 3
    Nov 18, 2026 6:07 AM UTC

    Hi ​@tcrewes1 

    The getQueryParam plugin is not inherently restricted to full-page loads. However, it is not SPA-aware either. It reads the query string from the URL at the time it is executed.

    In an SPA, URL changes through history.pushState() or history.replaceState() do not trigger a full-page reload. Therefore, the plugin will not automatically execute again to capture the updated query parameters.

    Try using the below flow maybe it could be of an help

    1. Create a Data Element using Core → Query String Parameter and specify the required parameter (e.g., utm_source).

    2. Create a rule with Core → History Change as the event to detect SPA route changes.

    3. Configure an Adobe Analytics action to set the required eVar using the Query String Parameter data element.

    4. Trigger the Track State / Send Beacon action after setting the variables.

    If the SPA uses custom routing, you can alternatively use a custom event triggered by the application after the URL is updated.

    One important point is ensure that the data element is evaluated after the URL changes and that its storage duration does not cause stale values to be returned.

     

    Translate
    Jennifer_Dungan
    Adobe Champion, Community Advisor, UG Leader
    Adobe Champion, Community Advisor, UG Leader
    Nov 18, 2026 9:54 PM UTC

    The other thing, if you are using Launch, you don’t need the old plugin… Launch has Query String Parameter Data Elements natively.

     

     

     

    Using the Storage Duration of “none” should force this to re-evaluate any parameters in the URL at the time the Data Element is used (whether it’s on Window Loaded, DOM Ready, or History Change, etc)

    Translate
    tcrewes1Author
    Level 3
    Nov 19, 2026 7:19 AM UTC

    Thanks Jennifer. Unfortunately, I’m not using Launch. I’ll look into why this isn’t working for me, even if I just paste the plugin function into the console it’s not picking up the URL. I think it’s possibly an issue with s.pageURL not updating correctly for some reason.

    Translate
    Jennifer_Dungan
    Adobe Champion, Community Advisor, UG Leader
    Adobe Champion, Community Advisor, UG Leader
    Nov 19, 2026 2:46 PM UTC

    OK, if you are not using Launch, I would personally extract the UTMs using standard JS over the Adobe Plugin… 

     

    The problem with the Adobe Plugin is that it’s not easy to trace if there are issues… I get that it was designed to just “plug and play” for non-developers… but standard JS is so easy to begin with…

     

    var searchParams = new URLSearchParams(window.location.search);

    var utmSource = searchParams.get('utm_source');
    var utmMedium = searchParams.get('utm_medium');
    // add the rest of your UTMs


    if (utmSource || utmMedium || ...){
    s.campaign = // build your format here
    }

     

    Try this… if you can see the URL Parameters in your address bar, and you said you can see them with standard JS, that’s probably a better solution than trying to debug the Adobe Plugin…. 

    Translate